change directory, cd

OSB

OSB

Associate
Joined
26 Nov 2003
Posts
932
Location
UK
I can use cd to change to a folder called for example "c++" (without the "") but how can i change to a directory called for example "Chemistry Labs"??

Thanks

OSB
 
When i try that i get:

soup:~$ cd /home/usr/Chemistry Labs
-bash: cd: /home/usr/Chemistry: No such file or directory
 
brilliant, that works thanks. One more quick question - is there a way to copy a file from a folder i'm in via an ssh session to the machine i am on?
 
I'd do it like Davey said. The interpreter, probably Bash, is a program that looks at what you typed and tries to figure out what it means. It understands spaces as separating things; commands from switches (like +x), arguments, paths, and other instructions. In order for it not to look at a space when it's not being used in that way you need to escape the cahracter. By putting a \ before a space you flag it as "don't pay attention to this space, it's all one thing." Other important and common programs work the same way, such as grep and sed.

cd /home/bti/BTI\'s\ Big\ Goat\ Porn\ Stash\!
will change to the directory /home/bti/BTI's Big Goat Porn Stash!

If you use tab completion it'll escape the characters for you. I suggest you use that.
 
If you use the tab key when typing in the shell Bash (the usual shell application) will automatically complete the rest of the line. Therefore, if you want to get to that directory, just type cd /hom (hit tab) to get cd /home/usr/Che (hit tab) and the path will be filled in automatically. This is a really handy feature and makes everything much easier with lots less typing.

Edit: Must type quicker...
 
brilliant, that works thanks. One more quick question - is there a way to copy a file from a folder i'm in via an ssh session to the machine i am on?
Sure, use scp, Secure CoPy.

Like so:
bti@btismachine:~$ssh somebodyelsesmachine
bti@somebodyelsesmachine:~$scp bti@btismachine:~/goatporn goatporn
bti@somebodyelsesmachine:~$logout
bti@btismachine:~$cd goatporn
bti@btismachine:~/goatporn

The syntax is
scp user@destination:\path\on\remote\machine \path\on\currently\logged\on\machine
 
I forgot, so used to doing it... I always use tab to complete my lines. Sorry. At least you're sorted now.
 
so do i need to know the address of the machine i'm on?

I want to copy a file from my account at uni, which i can get to using ssh no problems, to the laptop i am on atm.

What would the syntax be then?
 
Back
Top Bottom