I am trying to pass a variable with spaces to it using BASH, and in the tooltip it works fine:
$ tmp=/folder1/This Folder Here/randomfile.abc
$ echo "$tmp" | sed -e 's/ /\\ /g'
/folder1/This\ Folder\ Here/randomfile.abc
But as soon as I pass it to a variable, sed no longer replaces space with a backslash:
$ tmp=/folder1/This Folder Here/randomfile.abc
$ location=`echo "$tmp" | sed -e 's/ /\\ /g'`
$ echo $location
/folder1/This Folder Here/randomfile.abc
I hope that a second pair of eyes can raise what I do not know.
source
share