PDA

View Full Version : Can't change directory (spaces in file names?)


Rubidium
01-30-2002, 11:25 AM
Hello,

I am having trouble changing directories in the terminal window. Even though a ls -al lists an item as a directory, I have found that if it contains a space in the folder name, Unix comes back with:

Too many arguments.

I have also attempted to unrar some files, but cannot do so when the file name contains spaces.

I understand that spaces should be avoided in Unix file and directory names, but I have many folders and files with spaces in them that are effectively out of reach for me while using the command line. Is there a workaround for this?

Any hints or suggestions would be greatly appreciated!

Thanks!

Rubidium:)

Novajo
01-30-2002, 11:30 AM
You can use the following:

cd "My Directory with a space"
cd My\ Directory\ with\ a\ space

or even better: in the shell, if you type the first letter of a file:

cd My

then press the Tab key, it will be completed to the full name automatically:

cd My\ Directory\ with\ a\ space

rusto
01-30-2002, 11:51 AM
Right, the terminal requires you to type a \ to indicate that the next character is a space that is part of a filename or directory.

Tab completion of long paths and filenames is great...in the default tcsh shell, it even offers choices if what you tab out from is ambiguous.

cd /Li(tab)/Sc(tab)

will result in the shell suggesting:

Screen Savers/ Scripting Additions/ Scripts/

and repeating this:

cd /Library/Scr

To await you typing in the "e" that distinguishes "Screen Savers" from "Scripting Additions" or "Scripts", then hit (tab) again to finish and get this:

cd /Library/Screen\ Savers

Rubidium
01-30-2002, 11:57 AM
Thanks for the quick reply! I tried it just now and it works like a charm! The TAB completion is a very helpful feature. Thanks for introducing me to it!

Best regards,

Rubidium