A simple Bash script could do that:
#!/bin/bash
echo "\"$*\""
Already $*
generate the full list of arguments. echo
simply sourrounds them with escaped quotes.
myquote.sh hi, 'how do' you "do?"
"hi, how do you do?"
Now, related to the intended use of this 'quoter' script to put quotes around filenames obtained with find
in its exec
clause, it is not necessary, because you can add the quotes directly to the curly braces argument, like in this example, to be correctly received by the grep
command:
find /etc -exec grep -Hi "{}" \;
or, in case of piping to xargs
, using the -print0
clause to mark the filenames with a NULL delimiter for the xargs
command next in the pipe.
-print0
and-0
as you were already doing – muru Jan 07 '20 at 05:20find
(at least GNU one I have) does not work as would be expected if action expression is before criteria expressions, and I need to pass criteria (name) by xargs at the end. – Marisha Jan 07 '20 at 05:28-i
/-I
– muru Jan 07 '20 at 05:44