Low Orbit Flux Logo 2 D

AWK How To Print A Single Quote

You can use an octal escape code to print a single quote or apostrophe.

This example will print out the word test surrounded by single quotes.


awk 'BEGIN{print "\047test\047"}'

You could also assign the single quote to a variable using the “-v” flag. You can then just refer to the variable. This example will print the word test surounded by single quotes.


awk -v q="'" 'BEGIN{print q "test" q}'