Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 03: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, 03: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, 05: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, 05: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, 06: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, 06: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

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