Suppose I have a file containing a space in its name such as with space
. What should cmd
output in the below snippet for ls
to accept 'with space' as argument?
$ ls `cmd`
I tried ls `echo 'with space'`
. The arguments passed to ls
are 'with
and space'
. Trying to escape the space using backslash doesn't work either. I see that using ls "`cmd`"
works. But, this does not work if I want to pass multiple files as argument to ls
with some possibly containing spaces.
The manual on command substitution also appears sparse. https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html
More generally, what is the output format to be followed by cmd if it wants to output a list of files which can then substituted to be used by another command using backtick substitution?