When using \write18 to execute shell commands, there are some cases where lots of backslash strings, and other 'special' LaTeX characters are required in the commandline to be executed (e.g. if a regular-expression is needed, or when using awk).
It would be convenient to have a way of typing the command exactly as it should appear when used on the commandline (i.e. without needing to use \string, etc.), and having it parsed verbatim, and given as an argument to \write18. What ways are there of accomplishing this?
\unexpanded. By the way, the # -> ## problem (mentioned in Hendrik's comment below) still exists with\unexpanded. I guess one could write a\execunexpandedmacro which handles this? – Mark Mar 25 '11 at 11:01\unexpandedseems not to handle well is%. I guess one would need to do something similar with catcodes? – Mark Mar 25 '11 at 11:12\write18{\detokenize{...}}would also be a possibility, wouldn't it? – Martin Scharrer Jul 28 '11 at 00:16\percentchar-like macro but for$? – kiss my armpit Oct 07 '12 at 10:47\catcode`$=12– egreg Oct 07 '12 at 10:48\unexpandedit just worked to preserve the tilde in my path~/temp/myfile.log. Yeah! Thanks! :) – loved.by.Jesus Oct 21 '16 at 20:16