The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
reverse an integer ali560045 Shell Programming and Scripting 4 05-20-2008 04:15 AM
Cannot store integer value bennichan Shell Programming and Scripting 5 04-10-2008 03:20 PM
awk or grep for integer only apalex UNIX for Dummies Questions & Answers 5 09-01-2004 02:38 PM
integer arrays primal High Level Programming 4 03-09-2002 05:40 PM
How to get a rodom integer toddor High Level Programming 2 10-10-2001 08:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-29-2007
ericaworld ericaworld is offline
Registered User
  
 

Join Date: May 2007
Posts: 11
get integer part

Hi,
I did a df|awk| command and it returns a percentage "94%",
how could I only get the integer part
"94" out of it, so I can compare it to another number,

I knwo that I have to pipe it to sth, but "grep [0-9]" did not work, it still give me number WITH the percentage, does someone know what command I should pipe it to?

Sincerely,
  #2 (permalink)  
Old 05-29-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Erica,
See if this works for you:
Code:
...
echo '95%' | sed 's/%//'
  #3 (permalink)  
Old 05-29-2007
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Code:
echo '95%' | nawk '{print $1+0}'
  #4 (permalink)  
Old 05-29-2007
ericaworld ericaworld is offline
Registered User
  
 

Join Date: May 2007
Posts: 11
U Guys Are Awesome

BOTH method worked!!!!
u guys rocks
thanx a bunch
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0