|
|
|
|
|
by LegionMammal978
1828 days ago
|
|
I find it rather annoying to escape single quotes within single-quoted strings in the shell. Really, there are only two options, both of which are rather verbose: $ echo 'A'\''A, B'"'"'B'
A'A, B'B
I suppose that there's a few different commands that would work for your example: $ echo "One Two Three" | awk '{print "'"'"'"$2" here'"'"'"}' # original
$ echo "One Two Three" | awk {print\ \"\'\"\$2\"\ here\'\"}
$ echo "One Two Three" | awk '{print "'\''"$2" here'\''"}'
$ echo "One Two Three" | awk "{print \"'\"\$2\" here'\"}"
To be fair, though, the argument {print "'"$2" here'"} looks pretty weird if you're not used to working with awk. |
|