Reputation: 11
I Created a folder in desktop using GUI named ' \ ' after when i tried to delete that folder using terminal by rmdir . then i cant able to delete it . what is the reason for that ???
Upvotes: 0
Views: 793
Reputation:
You just need to give bash a command line that has an argument of a single \
(after bash expansion).
The easiest one is: rmdir '\'
The most basic is to escape the \
: rmdir \\
Or even inside double quotes: rmdir "\\"
Using an octal escape number: rmdir $'\134'
or rmdir "$(echo -e '\0134')"
or rmdir "$(printf '%b\n' '\134')"
Using an hexadecimal value: rmdir $'\x5c'
or rmdir "$(echo -e '\x5c')"
or rmdir "$(printf '%b\n' '\x5c')"
Upvotes: 1
Reputation: 44364
The problem is that \
is a special character that is intercepted and used by the shell ("expanded") before the rmdir
program gets it. So you need to quote the character to indicate that the shell should not mess with it. There are (at least) two ways:
rmdir \\
rmdir '\'
Note on the second one: single quotes, not double (\
is expanded inside double quotes).
Give that, as an exercise, how would you delete a directory called -\
?
Upvotes: 4
Reputation: 85683
You need to escape the character for deletion, rmdir \\
, add a -v
flag for verbose i.e. rmdir -v \\
$ mkdir \\
$ ls -lrt \\
total 0
$ rmdir -v \\
rmdir: removing directory, `\\'
Upvotes: 2