LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices

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.
Rate this Entry

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".
Posted in Uncategorized
Views 598 Comments 2
« Prev     Main     Next »
Total Comments 2

Comments

  1. Old Comment
    Thanks for this tip!
    Posted 11-19-2013 at 04:54 PM by vmccord vmccord is offline
  2. Old Comment
    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 goumba is offline
 

  



All times are GMT -5. The time now is 03:11 AM.

Main Menu

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration