LinuxQuestions.org
Help answer threads with 0 replies.
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 01-29-2013, 07:01 PM   #1
WalterWhite
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Rep: Reputation: Disabled
Unhappy File exists (ls) but no such file or directory (cd)


I am running on OSX 10.7.5. I run these commands in the terminal app, so I don't think there a 32 bit vs 64bit issue here. I have no idea what the problem is.
 
Old 01-29-2013, 07:03 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,557

Rep: Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116
Could you please post more information, such as the actual output of ls, the cd command, the error message, etc?
 
Old 01-29-2013, 07:44 PM   #3
WalterWhite
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
I found out that when the subdirectory is only one word such as Ruby instead of Ruby Code, then I can cd to the sub directory. When there is a space in the name apparently I can't, and I get back for cd Ruby Code

-bash: cd: Ruby: No such file or directory

Note that only Ruby is recognized. However when I use ls I get back Ruby Code.
 
Old 01-29-2013, 07:48 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Spaces (in file/dir names etc) are technically legal in *nix, BUT given that nearly all cmds default to assuming params are space separated, you can see that this will cause issues. I always use underscores instead and highly recommend you do something like that.

(BTW, in case you don't already know, *nix is case sensitive, so Ruby != ruby etc)
 
2 members found this post helpful.
Old 01-29-2013, 07:53 PM   #5
WalterWhite
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thank you Chris. Yes I got it that r != R. BTW is there any way to use escape characters or quotation marks to remove any ambiguity when there are spaces in directory names?

Walt
 
Old 01-29-2013, 08:00 PM   #6
WalterWhite
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
OK. I learned a little more. Commands like

mkdir "Ruby Code"

or

cd "Ruby Code"

work.

Using "Ruby/ Code" treats the '/' as just another character in the name.
 
1 members found this post helpful.
Old 01-29-2013, 08:00 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Yeah, try backslash or single quotes for immediate effect
Code:
Ruby\ Code

# or
'Ruby Code'
but note that that gets real old real fast , not to mention messy/complex when you write scripts and/or one-liners.
Seriously suggest you rename using underscores instead.
 
1 members found this post helpful.
Old 01-29-2013, 08:11 PM   #8
WalterWhite
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Cool! Apparently all 3 work:

cd "Ruby Code"

cd 'Ruby Code'

cd Ruby\ Code

Thanks Chris. Maybe I will do underscores it just that in finder on my mac those look kind of messy.

Maybe I will go with Ruby_Code.
 
Old 01-29-2013, 08:27 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
You may want to bookmark these, although note that OS/X is not exactly the same as Linux
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
Old 01-29-2013, 09:22 PM   #10
WalterWhite
LQ Newbie
 
Registered: Jan 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks Chris. Done.

Cheers,

Walt
 
  


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
[SOLVED] How to copy a file when destination directory does not exists. abhinav4 Linux - Newbie 6 10-01-2012 11:59 AM
[SOLVED] Bash: No such file or directory, when file actually exists. SkyerSK Linux - Software 13 02-06-2011 05:33 AM
cannot create directory even if file exists pratikvimal Linux - Newbie 7 06-15-2009 04:51 AM
no such file or directory exists when trying to execute a exe ryedawg Linux - Software 5 12-05-2005 06:42 AM
SIOCADDRT: File exists SIOCCADDRT: File Exists Failed to bring up eth0. opsraja Linux - Networking 0 01-10-2005 09:29 AM

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

All times are GMT -5. The time now is 06:13 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration