get integer part


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get integer part
# 1  
Old 05-29-2007
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  
Old 05-29-2007
Erica,
See if this works for you:
Code:
...
echo '95%' | sed 's/%//'

# 3  
Old 05-29-2007
Code:
echo '95%' | nawk '{print $1+0}'

# 4  
Old 05-29-2007
U Guys Are Awesome

BOTH method worked!!!!
u guys rocks
thanx a bunch
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to make a loop to read the input from a file part by part?

Hi All, We've a VDI infrastructure in AWS (AWS workspaces) and we're planning to automate the process of provisioning workspaces. Instead of going to GUI console, and launching workspaces by selecting individual users is little time consuming. Thus, I want to create them in bunches from AWS CLI... (6 Replies)
Discussion started by: arun_adm
6 Replies

2. Solaris

Integer Validation

Hi Using the below logic to check whether the value is integer or not and converting the value to decimal if not. int_chck = sprintf(substr($i, 1, 2)) o_cnt = 'if ; then echo $int_chck; else echo $((0x$int_chck)); fi' Thanks, Dines (4 Replies)
Discussion started by: dineshnak
4 Replies

3. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

4. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

5. Shell Programming and Scripting

Compare two files based on integer part only

Please see how can I do this: File A (three columns): X1,Y1,1.01 X2,Y2,2.02 X3,Y3,4.03 File B (three columns): X1,Y1,1 X2,Y2,2 X3,Y3,4.0005 Now I have to compare file A and B based on the integer part of column 3. Means first 2 rows should be OK and the third row should not satisfy... (12 Replies)
Discussion started by: yale_work
12 Replies

6. Shell Programming and Scripting

comparing part of header with part of detailed records.

Hi there, I am lil confused with the following issue. I have a File, which has the following header: IMSHRATE_043008_101016 a sample detailed record is :9820101 A982005000CAVG030108000000000000010169000MAR 2008 9820102 MAR 2008 D030108 ... (1 Reply)
Discussion started by: cmaroju
1 Replies

7. Shell Programming and Scripting

reverse an integer

i have created a script that will reverse any given ineter. #!/bin/ksh echo "Enter the number" read n if then a=`expr $n / 10` b=`expr $n % 10` c=`expr $b \* 10 + $a` fi echo $c --------------------------------------------------------------------- the problem with this script... (4 Replies)
Discussion started by: ali560045
4 Replies

8. Shell Programming and Scripting

Cannot store integer value

Hi , I have code like below in my ksh script, but getting an error as SP2-0253: data item 1 ("SAMPLE_ID") will not fit on line , pls help me. thanks. if (( CHECKS == 0 )) || (( CHECKS == 1 )) then V_SAMPLE_ID=$( $ORACLE_HOME/bin/sqlplus -S / <<EOF whenever sqlerror exit 1... (5 Replies)
Discussion started by: bennichan
5 Replies

9. IP Networking

how to pass integer

i am writing a client and server program client program main() { int sockfd,n; char str; struct sockaddr_in sock; if ((sockfd=socket(AF_INET,SOCK_STREAM,0))<0) { perror("SOCKET ERROR"); } bzero(&sock,sizeof(sock)); sock.sin_family=AF_INET; (1 Reply)
Discussion started by: ramneek
1 Replies

10. Programming

How to get a rodom integer

hi I want to get a rodom integer, but I just get the same integer while using the fuction rand() for the first time. So I wonder wether there is a way in which I can get an unknow random integer. Thanks in advance (2 Replies)
Discussion started by: toddor
2 Replies
Login or Register to Ask a Question