I have a directory called "foo bar baz blob". How can I
$ cd "foo bar baz blob"
I have tried with quoting (" and ') and with escaping the blanks (\ ). It does not work. Tab-completion does not work either.
I also have to issue commands with filename arguments that contain spaces. How do I do that? Even MidnightCommander (mc) fails in doing this.
EDIT
Over one year later, I finally found the source of my problem. I have overloaded the builtin cd with a function that automatically lists the files of the changed directory:
$ type cd
cd ist eine Funktion.
cd ()
{
if builtin cd $1; then
ls;
fi
}
$ cd Interner\ Speicher/
bash: cd: Interner: Datei oder Verzeichnis nicht gefunden
$ builtin cd Interner\ Speicher/
$ pwd
/run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C018%5D/Interner Speicher
$ ls
Alarms DCIM Movies Notifications Podcasts SmsContactsBackup
Android Download Music Pictures Ringtones
The solution is easy: I just have to put double quotes around the $1:
if builtin cd "$1"; then
Ooof. Thank you.
foo bar baz blob
directory within your current directory? Check withls
- if not you will need to add the absolute or relative path to the directory name.foo bar baz blob
folder in the home directory? By default, terminal opens 'in' the home directory, so the command would not work otherwise.This is how it should be escaped in terminal:cd foo\ bar\ baz\ blob/
.ls
in the directory and edit it in your question so we can see exactly what characters we are dealing with.