How to delete folder name is "-rlt"

Hi all

I cannot delete folder name is "-lrt".

 
drwxr-xr-x   2  sysadmin  sysadmin        2 Sep  5 15:52 -rlt
 
rm -r *rlt
rm: illegal option -- l
rm: illegal option -- t
usage: rm [-fiRr] file ...
 
rm -r "-rlt"
rm: illegal option -- l
rm: illegal option -- t
usage: rm [-fiRr] file ...
 
rm -r "\-rlt"
\-rlt: No such file or directory

Please help me delete it
Thanks,

This should work:

rm -r -- -rlt

or this:

rm -r ./-rlt

Thank you Scrutinizer.

try:

find . -type d -name '*rlt' | xargs rmdir

What you can do for those really crazy filenames is use the inode number:

# ls -i
297486 file
# find . -inum 297486 -exec rm -rf {} \; 

This problem come because the directory name has a starting minus sign in the name, and all the command line arguments starting with minus sign (e.g., -anything ) are treated as "switches". Switches are command line options. That is why the command responds by saying 'illegal option' (see your output). And there is no filename/directory left in the arguments list, so it says 'so such file or directory' .

The simplest get solution is to use './' before filename/directory name. i.e.

rm ./filename
rm -r ./directory/

Hope this is useful.
:slight_smile:

another way around the switches is the same as files with spaces in the names.

rm -r 'name'