I tried

export TASK=$HOME/Ubuntu\ One and export TASK="$HOME/Ubuntu One"

but neither works.

  • TASK or PATH? Are you setting PATH using TASK? If so, how? – Mikel Feb 14 '11 at 22:54

It's not the definition you're having issues with, it's the use.You need to wrap wherever you're using the variable in quotes. See this example:

oli@bert:~/Music$ export B="$HOME/Music/Yeah Yeah Yeahs/"
oli@bert:~/Music$ cd $B
-bash: cd: /home/oli/Music/Yeah: No such file or directory
oli@bert:~/Music$ cd "$B"
oli@bert:~/Music/Yeah Yeah Yeahs$


export TASK="$HOME/Ubuntu\ One"

In both exports you issued, when you echo $TASK, the result is

/home/user/Ubuntu One

This is not the expected behavior because when you write something like

cp $TASK/file somewhere_else/

bash will expand it to

cp /home/user/Ubuntu One/file somewhere_else/

which is, of course, incorrect.

Therefore, we need to put our path in quotation marks, and escape the space.

  • 1
    That's wrong. Did you try it? If you do this, cp sees the backslash, and cp doesn't handle backslashes, the shell does. – Mikel Feb 14 '11 at 22:56

This page explains the issue in detail. It's a good idea to read it thoroughly http://mywiki.wooledge.org/Arguments


This awkward and clumsy behaviour is the result of an unwise choice in the name of the "Ubuntu One" directory. Unfortunately, there seems to be no fix planned for this.

One option is to use Dropbox, which offers similar functionality.


Rather than resorting to Dropbox, I made a symbolic link:

ln -s Ubuntu\ One UbuntuOne

In my particular case I wanted to import python modules from a directory on my cloud:

ln -s Ubuntu\ One/pythonfiles pythonfiles
export PYTHONPATH="$PYTHONPATH:$HOME/pythonfiles/"

I agree, it is idiotic to put spaces in linux filenames.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.