8

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.
Aaron
  • 6,646
  • 5
  • 34
  • 48
kacpi2442
  • 107
  • 1
  • 4

2 Answers2

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
Wayne_Yux
  • 4,873
  • 3
  • 27
  • 35
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
heemayl
  • 90,425
  • 20
  • 200
  • 267