PDA

View Full Version : Command Line Basics - When to Use Spaces???



whiteowl
08-23-2004, 05:15 PM
Just getting into linux, and it's been years since DOS command line stuff. I can't recall why or when to use spaces in command line entries. Is it optional, it doesn't seem that way. What's the rule for spaces, especially before or after the slash (/) marks?

Thanks.

OErjan
08-23-2004, 06:37 PM
ok space is between the comand and a flag and between flag and whatever.
like in ls -a which is ls+space+-a+spcae+/home/username/, same with just the comand. just one space like so

ls /home/username
which is ls+space+/home/username

if you have space in a pathname, like:

ls -a /home/username/my files
you get errors. that is because it looks for a comand called files. if the space is before a / like :
ls -a /home/username/my files /new
that will be seen as new directory to list.
you can overcome this by using "\" like so:

ls -a /home/username/my\ files\ /new
or telling the comand that it should treat everything like one lump like so:

ls -a "/home/username/my files /new"
there are other ways aswell.

i hope this is what you wanted to know, if not keep asking.

whiteowl
08-23-2004, 08:54 PM
Thanks, your examples were very good, and I'm clearer on when to use spaces or not. I'm getting a couple cheat sheets on bash commands to further help. Now I've got to find out if installing Knoppix off CD to hard disk is similar to installing something like Xanrdos, PCLinuxOS, etc (re easier for new users).