Hi i am having a really strange problem.
I am trying to run the following scrip as root:
loc=$(transmission-remote 192.168.1.74:9091 --auth=user:password -t$TORRENTID -i |sed -e '1d;$d;s/^ *//'|grep Location: |cut -s -d : -f2)
cd "$loc"
But get the error messege :
cd: can't cd to /leprechaun_tv-shows/download/
But i works if i create a new string:
hello= /leprechaun_tv-shows/download/
cd $hello
what am i doing wrong?
Alternatively to Brian’s solution, if you still need
$locto be quoted incd "$loc"because the path could contain any spaces, then just usesed 's/^ *//g'to trim any leading spaces in$loc, like this: