I have some awk that rearrange a line. I would like to escape one of the variables (e.g. $_), in such way that "
and \
are escaped with a backslash.
Example:
echo "Ehm, \"hi\", he \\ said" | awk '{$1="" ; print "\"" $_ "\"" }'
" "hi", he \ said"
(do not change the echo, normally I read from a file that has Ehm, "hi", he \ said
in it).
I would like to have
" \"hi\", he \\ said"
instead. How can I do this? Is there a function in awk that can do this?