I wrote a small script that copies, then removes and then creates a symbolic link from where the file was moved to it’s new location.
To easly do it for multiple times I used variables, but when a file has spaces in it, I’m getting some errors, even though I’m using ‘\’ in front of every space.
Here is my code:
dest=~/Videos-win/file\ name\ with\ spaces
src=~/Downloads/file\ name\ with\ spaces
echo $dest ;
cp -r $src $dest ;
rm -R $src ;
ln -s $dest $src ;
echo 'done'
I also tried with ‘\\’ (adding ‘\ ‘ to the var). also got me some errors.
Anyone knows what am I doing wrong? tnx
Try this :
Please, USE MORE QUOTES! They are vital. Also, learn the difference between
'and"and `. See http://mywiki.wooledge.org/Quotes and http://wiki.bash-hackers.org/syntax/words