Following command
echo 'a b' 'c'
outputs
a b c
But the following
X="'a b' 'c'"
echo $X;
will outout
'a b' 'c'
I am searching a way to unquote $X , so that it will output "a b c" , but without losing the merged 'a b' argument. (= 2 arguments instead of 3, makes no difference for command 'echo', but for other commands like 'cp')
Try xargs:
$ echo $x
'a b' 'c'
$ echo $x | xargs ./echo
argc = 3
argv[0] = ./echo
argv[1] = a b
argv[2] = c
eval echo $x
this will pass a b
as first argument and c
as the second one
Note: this will actually evaluate arguments, eg:
$ x='$((3+5))'
$ eval echo $x
8
If that's not what you want use @vanza's xargs
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With