How to execute command from string containing spaces?
$ ls "xxx yyy"
a.exe
$ X="./xxx yyy/a.exe" ; $X
-bash: ./xxx: No such file or directory
$ X='./xxx yyy/a.exe' ; $X
-bash: ./xxx: No such file or directory
$ X="./xxx\ yyy/a.exe" ; $X
-bash: ./xxx: No such file or directory
How? Any ideas?
UPD. Found: $ X="./xxx yyy/a.exe" ; "$X"
.
UPD2. But I cannot pass arguments to it. This: $ X="./xxx yyy/a.exe" ; "$X" xxx
does not pass xxx
to $X
. Hot to do it? Any help? This $ X="./xxx\ yyy/a.exe" ; eval $X xxx
seems to work, but why there is a need to use eval
? Is it possible to avoid eval
?
To pass arguments use $ X="./xxx yyy/a.exe" ; "$X" xxx
.
$ X="./xxx yyy/a.exe" ; "$X" xxx
does not passxxx
to$X
" ... that works fine enough for me. – muru Apr 09 '22 at 11:27"$(X)" xxx
instead of"$X" xxx
. – pmor Apr 09 '22 at 11:33