problematic file name
Hi
I downloaded a file with a name starting with a hyphen, and I am having a whole lot of problem dealing with it because every command I used with it wanted to treat it as some kind of flag. Eventually, I used Konqueror to rename it, but the whole experience made me wonder if it is possible to work with such a filename in a shell. Suggestions? Thanks. |
One easy way is to add a leading "./".
Some commands have an "-f" switch that means a filename follows. Some commands accept "--" (two dashes) as a switch to mean that no more switches follow. If the remainder of the filename is fairly unique, you may be able to replace the '-' with a '?'. |
Just guessing: Enclose it in quotes, or put a \ right in front of the -
|
The best way is simply to use ./-filename, as KenJackson said. Stumped me for a while too.
|
If you have a look at the man pages for i.e. rm and mv, the option list can be terminated by '--'.
So mv -- -xxx.txt yyy.txt will move the file -xxx.txt to yyy.txt without problems. [edit]bit slow[/edit] |
Thanks for all your help.
And fyi, quotes and \ would not work because they just protect the string from the shell, and do not modify how the program, be it mv or rm, would parse the name. |
All times are GMT -5. The time now is 08:50 AM. |