How would I remove a file that has a name with non-letter characters in it?
Example: hello!.txt
When I try to use the "rm" command I get shell errors because of the exclamation point.
Printable View
How would I remove a file that has a name with non-letter characters in it?
Example: hello!.txt
When I try to use the "rm" command I get shell errors because of the exclamation point.
Escape the exclamation mark either by typing hello\!.txt (that's a backslash) or 'hello!.txt' (single quotes, double won't work).
What? I've always used double quotes without problems. :-? Figures...Quote:
Originally Posted by Dolda2000
It usually works, but ! is a very special character. I don't know exactly what it does, though, but it seems to be more internal than ordinary substitutions.
Say you created a file with the name
"dont worry, just looking around!?dont" decided that this wasn't such a good idea, and would like to remove it.
When I use the "rm" command, the shell tells me that it cannot find this file. I thought that this was because of the exclamation point, but even when I escape the exclamation point with a \ I still have problems. I also tried specifying the path like this: rm /home/users/user/"filename\!"
Works perfectly for me. Just enclose the file name in single quotes, or tab complete it.
about time someone said tab-complete ;-)
Let us all bow down before the altar of Tabcompletius and praise the Gods of Shell.Quote:
Originally Posted by majorwoo