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

_____________________________________________________________________________________________________________________

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 (580) General (60) Unix (47) Script (41) Blog (23) OCI (3) SQL* Loader (3) Datapump (2) Software (1)
DBA Tips
 

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