Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Dealing with file names (oddly) starting with an hyphen
Posted 11-19-2013 at 02:58 PM by the dsc
In a script or routine usage, you may stumble for some reason with a file starting with "-".
"ls *.lol" command in that dir will return error if the next character doesn't happen to be an option of "ls", and/or if it is an option, but the next part isn't coincidentally an "argument", which is probably unlikely.
The same applies for commands such as mv and rm.
but to deal with it you can issue something like
mv -- -weirdfilename.lol weirdfilename.lol
The "--" tells the command to ignore any further "options".
"ls *.lol" command in that dir will return error if the next character doesn't happen to be an option of "ls", and/or if it is an option, but the next part isn't coincidentally an "argument", which is probably unlikely.
The same applies for commands such as mv and rm.
but to deal with it you can issue something like
mv -- -weirdfilename.lol weirdfilename.lol
The "--" tells the command to ignore any further "options".
Total Comments 2
Comments
-
Thanks for this tip!
Posted 11-19-2013 at 04:54 PM by vmccord -
Hey, thanks for the tip.
This works for many (if not all) of the standard GNU file utils such as cp, rm, touch, etc.Posted 12-02-2013 at 07:35 AM by goumba