The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
"find command" to find the files in the current directories but not in the "subdir" swamymns Shell Programming and Scripting 9 07-22-2008 12:23 PM
Strange error "host: isc_taskmgr_create: no available threads" Santi Linux 0 01-03-2008 05:49 AM
Listing only directories in the current working directory using the "ls" command igandu UNIX for Dummies Questions & Answers 2 05-12-2006 05:47 AM
Unix "at" / "Cron" Command New Problem...Need help Mohanraj UNIX for Dummies Questions & Answers 3 01-26-2006 08:08 PM
chmod 777 on all directories below...how do I do that using the "find" command? Neko UNIX for Dummies Questions & Answers 7 07-12-2001 10:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-06-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Question bash: cd command to access "strange" directories

I have a problem using bash. Simply, I cannot find the right command (if there's one!) to enter in the "- Arch_02 -" directory. As you can see, the name begins with a hyphen and this is causing some trouble:


Code:
localhost arch2 # pwd
/mnt/arch2
localhost arch2 # ls -l
total 4
dr-x------ 1 root root 4096 2007-04-29 20:09 - Arch_02 -
dr-x------ 1 root root    0 2006-12-10 18:14 RECYCLER
dr-x------ 1 root root    0 2006-12-02 22:24 System Volume Information

localhost arch2 # cd -\ Arch_02\ -
bash: cd: - : invalid option
cd: usage: cd [-L|-P] [dir]

localhost arch2 # cd "- Arch_02 -"
bash: cd: - : invalid option
cd: usage: cd [-L|-P] [dir]

localhost arch2 # cd '- Arch_02 -'
bash: cd: - : invalid option
cd: usage: cd [-L|-P] [dir]

localhost arch2 # cd - -\ Arch_02\ -
/root

localhost ~ # cd /mnt/arch2

localhost arch2 # cd - "- Arch_02 -"
/root


If I use csh instead, I can regularly access the directory by issuing the command:

Code:
(localhost:/mnt/arch2) # cd "- Arch_02 -"
(localhost:/mnt/arch2/- Arch_02 -) # pwd
/mnt/arch2/- Arch_02 -

With bash completion, if I press tab while typing directory's name, I can also see the subdirectories under "- Arch_02 -", but cannot access them with cd!

Does anyone have the answer?

Thanks a lot!
  #2 (permalink)  
Old 07-06-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,429

Code:
cd -- '- Arch_02 -'

  #3 (permalink)  
Old 07-06-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Here is how you can do it:

Code:
cd ./*Arch_02*


Last edited by Shell_Life; 07-06-2007 at 05:50 PM..
  #4 (permalink)  
Old 07-06-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Wow! Many many thanks! Both solutions are working great.

By the way, now that I have the answer I think I should have read more carefully the options in man bash
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0