LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-20-2007, 01:42 PM   #1
zeeple
Member
 
Registered: Sep 2006
Distribution: Fedora 8, RHEL 5
Posts: 62

Rep: Reputation: 15
rename dir with dashes in name


I recently had to unzip a mail archive and one of the users had a mail folder called:

---------Archive

They obviously put all the dashes to move it to the top of some tree, or maybe to make it stand out more. Regardless, I cannot get into it now:

[joe@mail1 inbox]# cd --------Archive
-bash: cd: --: invalid option
cd: usage: cd [-L|-P] [dir]
[joe@mail1 inbox]# cd '--------Archive'/
-bash: cd: --: invalid option
cd: usage: cd [-L|-P] [dir]
[joe@mail1 inbox]# cd "--------Archive"/
-bash: cd: --: invalid option
cd: usage: cd [-L|-P] [dir]

Notice that single quotes and double quotes yield the same result. Other operations (rm mv) result in the same. Any suggestions?
 
Old 11-20-2007, 01:48 PM   #2
zeeple
Member
 
Registered: Sep 2006
Distribution: Fedora 8, RHEL 5
Posts: 62

Original Poster
Rep: Reputation: 15
solved

The answer was simple:

cd ./--------Archive

was what worked
 
Old 11-20-2007, 01:49 PM   #3
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
You can use "--" as an argument to say that you will not be using any more flags. Thus it will not interpolate any of the dashes as additional flags. That, or you can escape them all.

$ cd -- "-----stuff/"
$ rm -rf -- "-----stuff/"

et cetera
 
Old 11-20-2007, 01:51 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Try this:

cd -- --------Archive

The -- tells cd that all after it is part of the directory name.

To rename the ------Archive directory: mv -- ------Archive/ Archive

To remove it: m -rf -- ------Archive

Hope this helps

PS: To create one: mkdir -- ------Archive
 
Old 11-20-2007, 01:57 PM   #5
zeeple
Member
 
Registered: Sep 2006
Distribution: Fedora 8, RHEL 5
Posts: 62

Original Poster
Rep: Reputation: 15
Excellent suggestions! Thanks everyone for the contribution!
 
  


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
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 02:57 PM
Typing em dashes? culturejam Linux - General 1 12-13-2004 10:11 AM
Dashes in Grub.conf herkdrvr Linux - Newbie 2 10-12-2004 08:33 AM
rename script all files in dir Longinus Linux - Newbie 8 08-02-2004 12:24 AM
auto rename contents of a DIR bkeating Linux - General 1 11-05-2002 06:34 PM

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

All times are GMT -5. The time now is 09:15 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