I was working on a shell script and I accidentally created a file with the variable as its name. Now I have $file in my ls output, and cannot remove it. What can I do?
Tell me more
×
Unix & Linux Stack Exchange is a question and answer site for
users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
|
|
||||
|
|
|
You can escape the
|
|||||||
|
|
You can also do
Stuff in single quotes is taken as literal always,so globs and variables don't get expanded. |
|||
|
|
|
Basically, if you want to do things literal with these weird characters, you need to escape it. In a shell there are several ways to do that. The first one is to prepend a '\' to every character you want to escape. So you can do
or
or
|
|||
|
|
|
If you ever accidentally create a file named |
|||||
|