Visit The New, Modern Unix Linux Community

bash: cd command to access "strange" directories

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash: cd command to access "strange" directories
# 1  
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:

localhost arch2 # pwd
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\ -

localhost ~ # cd /mnt/arch2

localhost arch2 # cd - "- Arch_02 -"

If I use csh instead, I can regularly access the directory by issuing the command:
(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  
cd -- '- Arch_02 -'

# 3  
Here is how you can do it:
cd ./*Arch_02*

Last edited by Shell_Life; 07-06-2007 at 05:50 PM..
# 4  
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 Smilie

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #925
Difficulty: Medium
The earliest versions of Unix time had a 32-bit integer incrementing at a rate of 60 Hz.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Why awk print is strange when I set FS = " " instead of FS = "\t"?

Look at the following data file( which has four fields separated by tab. Four fields are country name, land area, population, continent where it belongs. As for country name or continent name which has two words, two words are separated by space. (Data are not accurately... (1 Reply)
Discussion started by: chihuyu
1 Replies

3. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. Shell Programming and Scripting

Strange "cut" command's behaviour

Hi, Suppose if I have a file having data like this: $ cat file.txt A B C D And, if I do a cut operation like this: $ cut -d" " -f2 file.txt The output is A C D This is the same for even if we try to get the field 3 with -f3 (assume line 2 has 3 fields : C E F). The above... (1 Reply)
Discussion started by: royalibrahim
1 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. AIX

Typing "bash" at the command line spawns two bash processes

Server: IBM p770 OS: AIX 6.1 TL5 SP1 When one of our develoeprs types "bash" on the command line to switch shells, it hangs. For some reason, two bash processes are created....the first bash process spawns a second bash process in the same console, causing a hang. Anyone have any idea what... (2 Replies)
Discussion started by: wjssj
2 Replies

8. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

9. UNIX for Dummies Questions & Answers

Listing only directories in the current working directory using the "ls" command

Hello All, I am trying to list only directories in my current directory using the command "ls -d". But the output only contains the default directory "." and doesn't list the rest of the directories in the working directory. Can anyone explain why this is happening (2 Replies)
Discussion started by: igandu
2 Replies

10. UNIX for Dummies Questions & Answers

chmod 777 on all directories do I do that using the "find" command?

I've got 100 directories that each have 2 directories with in them. Structered like this: /home/domains/domain1/ through to /home/domains/domain100/ and those 2 directories mentioned above are here: /home/domains/domain1/directory1/ /home/domains/domain1/directory2/ through to... (7 Replies)
Discussion started by: Neko
7 Replies

Featured Tech Videos