Tuesday, May 13, 2008

Linux:Bash:how to print quotation marks in awk

ls | awk '{print "'\''"$1"'\''"}'

or

awk 'BEGIN { print "Here is a single quote \47" }'

4 comments:

Pacjack said...

And how to print a double quotation mark (")?
As
# ls | awk '{print "'\"'"$1"'\''"}'
doesn't work.

Sun life said...

Even simpler:

ls | awk '{print "\""$1"\""}'

Blog de Marco said...

awk '{print "\047between double quotes\047"}'

Blog de Marco said...

sorry \47

Locations of visitors to this page