Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-08-2007, 01:52 AM   #1
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Rep: Reputation: 16
[SOLVED]How to deal with filenames starting with "-" or "--"?

How can I deal with filenames starting with "-" or "--"?
I can list, rename, move, copy, delete them through the GUI, but I am unable to do this through the command-line.

What's the trick to use such filenames like "--fobar" in a command-line?
Whatever I do (",',\), bash seems to interpret the -* as an option, so I keep getting an "unrecognized option" error.

Last edited by [KIA]aze; 07-08-2007 at 02:34 AM.
Old 07-08-2007, 02:09 AM   #2
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
After the last switch (if any), use "--" by itself, and anything after that will be interpreted as a filename.


wally:~/saturday$ ls
wally:~/saturday$ touch -- -abcd
wally:~/saturday$ touch -- --abcd
wally:~/saturday$ ls
--abcd  -abcd
wally:~/saturday$ # following will fail because it seems like "ls --abcd -abcd"
wally:~/saturday$ ls *abcd
ls: unrecognized option `--abcd'
Try `ls --help' for more information.
wally:~/saturday$ # but this will work:
wally:~/saturday$ ls -- *abcd
--abcd  -abcd
Hope this helps.
Old 07-08-2007, 02:31 AM   #3
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Original Poster
Rep: Reputation: 16
Thanks, that works.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
what is "sticky bit mode" , "SUID" , "SGID" augustus123 Linux - General 10 08-03-2012 05:40 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 12:26 PM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 04:07 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 09:31 AM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 02:34 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:29 PM.

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