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 > awk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-06-04, 02:30
preetikate preetikate is offline
Registered User
 
Join Date: Jan 2004
Posts: 84
awk

echo $LINE | awk '{print $3}' is 97% but I want only 97 for computation... how do i extract " % "
Reply With Quote
  #2 (permalink)  
Old 02-06-04, 02:32
preetikate preetikate is offline
Registered User
 
Join Date: Jan 2004
Posts: 84
I mean I want 97 only and not % sign with it for computation
Reply With Quote
  #3 (permalink)  
Old 02-06-04, 04:46
spvijay spvijay is offline
Registered User
 
Join Date: Feb 2004
Location: Eternity
Posts: 31
Try
echo $line | awk '{print $3}' | cut -d"%" -f1

Thanx
Vijay
Reply With Quote
  #4 (permalink)  
Old 02-06-04, 04:58
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
echo $LINE | awk '{sub(/%/,"",$3) ; print $3}'
__________________
Jean-Pierre.
Reply With Quote
  #5 (permalink)  
Old 02-06-04, 05:15
preetikate preetikate is offline
Registered User
 
Join Date: Jan 2004
Posts: 84
what is f1 for?
Thanks anyways..
Reply With Quote
  #6 (permalink)  
Old 02-06-04, 05:19
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
cut -d"%" -f1

-d"%" Specify field delimitor as "%"
-f1 Get field 1
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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