command substitution but without breaking output into multiple arguments command substitution but without breaking output into multiple arguments shell shell

command substitution but without breaking output into multiple arguments


cd "$(xsel)"

seems to handle all special characters (including $ and spaces).

My test string was boo*;cd.*($\: $_

$ mkdir "$(xsel)"$ lsboo*;cd.*($\: $_$ file boo\*\;cd.\*\(\$\\\:\ \$_/boo*;cd.*($\: $_/: directory$ cd "$(xsel)"$ pwd/tmp/boo*;cd.*($\: $_


Have you tried:

cd "`xsel`"

That should do the job, unless you have dollars($) or back-slashes (\) in your path.


If you aren't doing this programmatically, most terminals in Linux let you paste from the clipboard with a middle-click on your mouse. Of course, you'll still need to put quotes before and after your paste, like @dave suggests.