I want to set an environment variable that has space in it.
It is a path to a folder and the folder name is:
/home/mehrabib/my video
I edit .bashrc and add the following line to it:
export $VIDEO=/home/mehrabib/my\ video
and run these commands:
echo $VIDEO
cd $VIDEO
The result is:
/home/mehrabib/my video
/home/mehrabib/my :no such file or directory
I change it to
export $VIDEO=/home/mehrabib/my\\\ video
and run these commands:
echo $VIDEO
cd $VIDEO
The result is:
/home/mehrabib/my\ video
/home/mehrabib/my\ :no such file or directory
What should I do?
You should do
and to sum Dan’s comments up also do
which will expand to
again.
Personally, I’ve come to prefer the
${VIDEO}syntax.