How do you use spaces with terminal?

Status
Not open for further replies.

CrazeD

Fully Optimized
Messages
3,736
Location
Maine
I got Ubuntu 6.06 32-bit on my spare machine just to screw around with it. It's pretty cool so far, and I'm currently learning all the bash commands.

So, with bash, how do you work in a space in a file?

Example: Say I want to delete the file "file one". I can do "rm file one" but that counts it as deleting two files named "file" and "one".

I hope you understand my question. :)
 
I dont remeber the exact escape sequence for space, but you can always hit the TAB key to auto-fill out the closest file name. (ie type -> "rm file" then hit the TAB key.)
 
Sweet, thanks.

By hitting TAB I have learned that you would type "rm file\ one/".

:)
 
If there's a space in the filename, just put a \ before the space, so it sort of comments it out. For example:

Code:
ted-roddys-computer:~ Ted$ ls
Desktop         Library         Pictures        Sites
Documents       Movies          Public          Torrents
Incomplete      Music           Shared          vmware
ted-roddys-computer:~ Ted$ touch file\ name.txt
ted-roddys-computer:~ Ted$ ls
Desktop         Library         Pictures        Sites           vmware
Documents       Movies          Public          Torrents
Incomplete      Music           Shared          file name.txt
ted-roddys-computer:~ Ted$ rm file\ name.txt 
ted-roddys-computer:~ Ted$ ls
Desktop         Library         Pictures        Sites
Documents       Movies          Public          Torrents
Incomplete      Music           Shared          vmware
ted-roddys-computer:~ Ted$

Does this make sense to you? I made the file with touch, then removed it. The \ will disregard the next character ...

Meh..
 
you guys are making this WAY harder than it is just do

$rm "file one"

the quotes arount the file make it literal, so u could do this

$rm "/home/jon boy/Desktop/File with spaces/file name.txt"
 
jonmon6691 said:
you guys are making this WAY harder than it is just do

$rm "file one"

the quotes arount the file make it literal, so u could do this

$rm "/home/jon boy/Desktop/File with spaces/file name.txt"

With mine, I add 1 symbol, with yours you add 2. How is yours simpler than mine?
 
The General said:
With mine, I add 1 symbol, with yours you add 2. How is yours simpler than mine?

He's saying it would be easier to use quotes if there is a say more than one space.

Either way works, thanks guys.
 
Status
Not open for further replies.
Back
Top Bottom