You cannot escape single quotes as the command itself is surrounded by single quotes, but you could use an octal escape code \047
to represent '
in POSIX awk. Additionally, you could use a hexadecimal escape code \x27
in GNU awk (gawk
).
From The GNU Awk User’s Guide, 3.2 Escape Sequences:
\nnn
The octal value nnn
, where nnn
stands for 1 to 3 digits between ‘0’
and ‘7’. For example, the code for the ASCII ESC (escape) character is
\033
.
\xhh…
The hexadecimal value hh
, where hh
stands for a sequence of
hexadecimal digits (‘0’–‘9’, and either ‘A’–‘F’ or ‘a’–‘f’). A maximum
of two digits are allowed after the \x
. Any further hexadecimal
digits are treated as simple letters or numbers. (c.e.) (The \x
escape sequence is not allowed in POSIX awk.)
awk 'NR==90 { print "define(\`RELAY_MAILER_ARGS\047, \`TCP $h 2525\047)dnl"}1' example.com.mc
gawk 'NR==90 { print "define(\`RELAY_MAILER_ARGS\x27, \`TCP $h 2525\x27)dnl"}1' example.com.mc
If you would like to also use \140
(or \x60
) to represent the backtick:
awk 'NR==90 { print "define(\140RELAY_MAILER_ARGS\047, \140TCP $h 2525\047)dnl"}1' example.com.mc
gawk 'NR==90 { print "define(\x60RELAY_MAILER_ARGS\x27, \x60TCP $h 2525\x27)dnl"}1' example.com.mc