Different Methods to Print Single Quote (') in AWK programming

This is my input file

cat dat
NO         TAG20111217T004155
YES        TAG20111217T004157
YES        TAG20111217T004157


I want the output in following format
'TAG20111217T004155'
'TAG20111217T004157'
'TAG20111217T004157'

Method 1:
awk -v rep="'"  '{ print  q $2 q}' dat
TAG20111217T004155
TAG20111217T004157
TAG20111217T004157

Method 2:

awk -v rep="'"  '{ print  rep $2 rep}' dat
'TAG20111217T004155'
'TAG20111217T004157'
'TAG20111217T004157'

Method 3:

$ awk '{ print  "'"'"'" $2 "'"'"'" }' dat
'TAG20111217T004155'
'TAG20111217T004157'
'TAG20111217T004157'

Method 4:

awk '{ print "'\''" $2 "'\''" }' dat
'TAG20111217T004155'
'TAG20111217T004157'
'TAG20111217T004157'
DBA Tips Data Pump Reference

0 comments:

Post a Comment

 

dba topics. Copyright 2011-16 All Rights Reserved | Site Map | Contact | Disclaimer | Google