Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
single quote usage in awk
single quote using in awk
###### Using Single QUote in awk script
function ltrim_single_quote(s) { return sub(/^\047+/, "", s); return s}
function rtrim_single_quote(s) { return sub(/'\047+$/, "", s); return s}
function trim_single_quote(s) { return ltrim_single_quote(rtrim_single_quote(s)) }
* [reference 1](
###### Using Single Quote in command line
This command will print "'demo'":
* Using variable
`echo 'demo' | awk -v q=\' '{printf "%s%s%s\n", q, $0, q}'`
* Using hex or octal representation of the ascii character
`echo 'demo' | awk '{printf "\x27%s\x27\n", $0}`
`echo 'demo' | awk '{printf "\047%s\047\n", $0}`
* [reference 1](
* [regerence 2](
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.