LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-08-2007, 12:52 AM   #1
[KIA]aze
Member
 
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 01:34 AM.
 
Old 07-08-2007, 01:09 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

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

Example:

Code:
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
wally:~/saturday$
Hope this helps.
 
Old 07-08-2007, 01:31 AM   #3
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

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


Reply


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 04:40 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 01:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:37 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration