TASK=$HOME/Ubuntu\ One and export
but neither works.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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
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.
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.