I would like to output the list of items in a folder in the folowing way:
\"filename1\" \"filename2\" \"file name with spaces\" \"foldername\" \"folder name wit
EDIT:
The following answer generate a new-line separated LIST instead of a single line.
| tr '\n' ' '
)A less mentioned method is to use -d
(--delimiter
) option of xargs
:
find . | xargs -I@ -d"\n" echo \"@\"
-I@
captures eachfind
result as@
and then we echo-ed it with quotes
With this you can invoke any commands just as you added quotes to the arguments.
$ find . | xargs -d"\n" testcli.js
[ "filename1",
"filename2",
"file name with spaces",
"foldername",
"folder name with spaces" ]
See https://stackoverflow.com/a/33528111/665507