I have a file named "-t". How to remove it? [duplicate]
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.
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
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