If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How i can print single quota in awk print command

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-24-09, 11:38
wrabanal wrabanal is offline
Registered User
 
Join Date: Feb 2009
Posts: 6
Post How i can print single quota in awk print command

I have the follow command

ls -l | grep 'Feb 21' | awk '{print "awk /SESSIONID:/ {print $0} "$9 ">> join.file" }'> a.a

The commando run sucessfully

But i need put single quota in print

Like that

ls -l | grep 'Feb 21' | awk '{print "awk '/SESSIONID:/ {print $0}' "$9 ">> join.file" }'> a2.a

and begin '/SESSIONID
and the end $0}'

But if i try run this command.. i have an error

oracle [Amadeus1]% ls -l | grep 'Feb 21' | awk '{print "awk '/SESSIONID:/ {print $0}' "$9 ">> join.file" }'> a2.a
awk: Cannot find or open file {print.

The source line number is 1.
oracle [Amadeus1]%


how i can put this single quota in awk print command

Thanks
Reply With Quote
  #2 (permalink)  
Old 02-24-09, 12:04
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,517
did your other question this morning get answered fully?
Reply With Quote
  #3 (permalink)  
Old 02-24-09, 13:07
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,578
Escape the single quote inside the AWK script:
Code:
awk '{ ... \' ... }'
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 02-24-09, 14:31
wrabanal wrabanal is offline
Registered User
 
Join Date: Feb 2009
Posts: 6
Dont work

I apply your recomendation but, dont work

When i executed, dont do it anything.


% ls -l | awk '{print "awk \'/SESSIONID:/ {print $0}\' "$9 ">> join.file" }'> a.a
>
>
>ctrol +C
%
Reply With Quote
  #5 (permalink)  
Old 02-24-09, 14:41
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,578
Then you can use the hex code point for the character (assuming you use ASCII/UTF-8):
Code:
awk '{print "\x27" $0; }'
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #6 (permalink)  
Old 02-24-09, 15:46
wrabanal wrabanal is offline
Registered User
 
Join Date: Feb 2009
Posts: 6
Red face dont work again

I try but dont work

oracle [Amadeus1]% ls -l | awk '{print "awk \x27/SESSIONID:/ {print $0}\x27 "$9 ">> join.file" }'> a.a
awk x27/SESSIONID:/ {print $0}x27 ora_1000038.aud>> join.file
awk x27/SESSIONID:/ {print $0}x27 ora_1000691.aud>> join.file
awk x27/SESSIONID:/ {print $0}x27 ora_1000736.aud>> join.file
awk x27/SESSIONID:/ {print $0}x27 ora_1000808.aud>> join.file
awk x27/SESSIONID:/ {print $0}x27 ora_1000935.aud>> join.file

put x27 when must be put '

Any other idea.

Regards.
Reply With Quote
  #7 (permalink)  
Old 02-24-09, 20:23
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,578
It works fine for me:
Code:
$ awk '{print "\x27" $0; }' < /etc/resolv.conf
'### /etc/resolv.conf file autogenerated by netconfig!
'#
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #8 (permalink)  
Old 02-25-09, 14:51
wrabanal wrabanal is offline
Registered User
 
Join Date: Feb 2009
Posts: 6
Red face Dont work

My S.O is Tru 64 unix.

Regards,
Reply With Quote
  #9 (permalink)  
Old 02-25-09, 18:39
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,578
Then check if you have GNU awk installed - maybe it is named "gawk"?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On