8

This question already has an answer here:

Output of "ls -l":

-rw-r--r--  1 root root    0 Mar  4 08:22 -t

When i try to do "rm '-t'":

rm: invalid option -- 't'
Try 'rm ./-t' to remove the file '-t'.
Try 'rm --help' for more information.

marked as duplicate by Seth Mar 22 '16 at 17:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 21
    So Try 'rm ./-t' to remove the file '-t'. – Pilot6 Mar 22 '16 at 10:16
  • 1
    Did you read your own question at all? – Dmitry Grigoryev Mar 23 '16 at 20:04
24

You can use rm -- -t or rm ./-t

From man rm

To remove a file whose name starts with a '-', for example '-foo',
use one of these commands:

          rm -- -foo

          rm ./-foo
6

You can use find too:

find . -maxdepth 1 -type f -name '-t' -delete 

Example:

% ls 
egg -t

% find . -maxdepth 1 -type f -name '-t' -delete 

% ls
egg

Not the answer you're looking for? Browse other questions tagged or ask your own question.