Results 1 to 5 of 5
n00b note: I'm not sure that it makes any difference, but in this post when I say "shell" I mean the shell that is brought up by default in KDE's ...
- 07-22-2007 #1Just Joined!
- Join Date
- Jun 2007
- Location
- Adrift in an ever-expanding universe, quietly contemplating the wondrous and the inevitable.
- Posts
- 82
The shell and spaces...
n00b note: I'm not sure that it makes any difference, but in this post when I say "shell" I mean the shell that is brought up by default in KDE's Konsole. (I don't yet know if it's bash or what.)
So... just exactly *as what* does the shell interpret spaces in a command?
If they're interpreted as separators, then how is it that I'm encountering files with spaces in the filename? I've d/l'ed, for instance, a file from KDE-Look.org which ls displays asBeing a dutiful little n00b, I've tried to clean up after myself. Here is the result of mv when removing the spaces from the filename54701-Kore - Beryl Themes.tar.gzAfter checking and rechecking my syntax I tried leaving the spaces intact and was (to no surprise) still unable to move the file:user@user-desktop:~$ sudo mv /home/user/54701-Kore-BerylThemes.tar.gz /home/user/downloads/themes
mv: cannot stat `/home/user/54701-Kore-BerylThemes.tar.gz': No such file or directoryMy only previous command line experience being limited mainly to DOS; I tried truncating, then substituting underscore for space. I was still unable to move the file.user@user-desktop:~$ sudo mv /home/user/54701-Kore - Beryl Themes.tar.gz /home/user/downloads/themes
mv: cannot stat `/home/user/54701-Kore': No such file or directory
mv: cannot stat `-': No such file or directory
mv: cannot stat `Beryl': No such file or directory
mv: cannot stat `Themes.tar.gz': No such file or directory
So tell me please... what gives? Is there some rule that I'm not aware of? What's up with those spaces being displayed? And what's preventing me from moving this file?
Thx!
qv
- 07-22-2007 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Spaces seperate arguments to a command, such as a switch or a filename. If you need to use a space as part of a filename you can delimit it using a backslash. Just put a backslash before any space. You need to do this with some operators such as exclamation marks (!) and brackets.
Code:54701-Kore\ -\ Beryl\ Themes.tar.gz
- 07-22-2007 #3
You can use the "dir" command to see exactly what bigtomrodney is talking about too.
from a shell, type dir instead of lsI do not respond to private messages asking for Linux help, Please keep it on the forums only.
All new users please read this.** Forum FAQS. ** Adopt an unanswered post.
- 07-22-2007 #4Linux User
- Join Date
- Jun 2007
- Posts
- 318
When dealing with filenames that have spaces in them you also can enclose them in either single or double quotes:
'54701-Kore - Beryl Themes.tar.gz'
or
"54701-Kore - Beryl Themes.tar.gz"
Also, if the filename has dollar signs ($) in them then you have to use single quotes:
'54701-Kore $ Beryl Themes.tar.gz'
- 07-22-2007 #5Just Joined!
- Join Date
- Jun 2007
- Location
- Adrift in an ever-expanding universe, quietly contemplating the wondrous and the inevitable.
- Posts
- 82
Amazing. Just... amazing! Thank you, guys.
qv


Reply With Quote