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

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World
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'

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer