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 12-01-2014, 02:19 AM   #1
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Rep: Reputation: Disabled
how to cd directory


in my system , there is directory "R & D" , I can't cd to this directory .

I tried the following , but not work , would advise how to cd to it ? thanks

#cd R\ &
 
Old 12-01-2014, 02:36 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,880
Blog Entries: 1

Rep: Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998
Code:
cd R\ \&\ D
Should work

But better would be...

Code:
mv R\ \&\ D R_AND_D
cd R_AND_D
Spaces and special characters in file and directory names is a bad habit taught by another OS.
 
Old 12-01-2014, 02:41 AM   #3
byran cheung
Member
 
Registered: Sep 2013
Posts: 321

Original Poster
Rep: Reputation: Disabled
it works, thanks
 
Old 12-01-2014, 03:21 AM   #4
albinodrew
LQ Newbie
 
Registered: Mar 2014
Location: Quebec, Canada
Distribution: Debian 8 - Jessie
Posts: 20

Rep: Reputation: 5
You can also do like this

cd "R & D"
 
Old 12-01-2014, 05:46 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,120

Rep: Reputation: 2269Reputation: 2269Reputation: 2269Reputation: 2269Reputation: 2269Reputation: 2269Reputation: 2269Reputation: 2269Reputation: 2269Reputation: 2269Reputation: 2269
or probably
cd R*D
but as it was mentioned: avoid using "strange" characters, like ?!&<> (and space) in filenames
 
Old 12-01-2014, 09:23 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,096
Blog Entries: 10

Rep: Reputation: 1522Reputation: 1522Reputation: 1522Reputation: 1522Reputation: 1522Reputation: 1522Reputation: 1522Reputation: 1522Reputation: 1522Reputation: 1522Reputation: 1522
As mentioned the space and other special characters need to be escaped with the backslash. You can use quotes and sometimes it's best once you get a directory name like that, say from an archive or something, to just change the name, especially if you plan to use the command line to enter and refer to the directory name. In scripts this is the similar problem you'll need to escape or use the double quotes all the time.
 
  


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] Invoke root directory owner/group while moving file/directory yogesh_attarde Linux - Security 5 04-15-2014 12:36 AM
[SOLVED] Modify the directory entry structure of a directory to show manipulated data shreyas08 Linux - Newbie 1 12-13-2011 06:34 AM
Username & Password Sync Fedora Directory and Microsoft Active Directory karnac01 Fedora 4 07-19-2010 01:51 AM
change default vsftp anonymous accout directory /var/ftp to other directory? hocheetiong Linux - Newbie 2 01-24-2010 07:33 PM


All times are GMT -5. The time now is 06: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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration