Df -h | awk - output incorrect matching


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Df -h | awk - output incorrect matching
# 1  
Old 03-11-2014
Df -h | awk - output incorrect matching

Running solaris 9, on issuing the follwing command
Code:
df -h | awk '$5 > 45 {print}'

Filesystems with utilisation > 45% are being displayed as well as those between
5 and-9%!!!
# 2  
Old 03-11-2014
Try this
Code:
df -h | awk '$5+0 > 45'

If it doesn't work, provide the output of df -h

And in Solaris, use nawk

Last edited by ahamed101; 03-11-2014 at 07:25 AM..
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 03-11-2014
nawk gives the same response as awk
Code:
$  df -h | awk '$5 > 75 {print}'
Filesystem             size   used  avail capacity  Mounted on
a/b/c/         20G   1.4G    18G     8%    /blah/blah
w/x/y        30G    24G   5.6G    82%    /some/where

---------- Post updated at 10:58 AM ---------- Previous update was at 10:47 AM ----------

I've managed to resolve the issue by doing the following

Code:
df -h | tr -d '%' | awk '$5 > 75 {print}'

# 4  
Old 03-11-2014
Hello,

Could you please try following.

Code:
df -h | tr -d '%' | awk 'NR==1 {next} $5+0 > 75 {print}' 
 
OR
 
df -h | tr -d '%' | awk '$5+0 > 75 {print}'



Thanks,
R. Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk incorrect format

I was wondering whether anyone has any idea what is happening here. I'm using simple code to compare 2 tab delimited files based on column 1 values. If the column1 value of file1 exists in file2, then I'm to print the column4 value in file2 in column3 of file1. Here is my code: 1st I have to... (6 Replies)
Discussion started by: Geneanalyst
6 Replies

2. Shell Programming and Scripting

Script showing incorrect output

Hello scripting geeks, I am new to scripting and facing some issues in writing the logic of the script. Request your kind help here Actually when i run a command i get o/p as below o/p : 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 these are hex values i guess...now i want to... (15 Replies)
Discussion started by: kulvant29
15 Replies

3. Shell Programming and Scripting

Output counts of all matching strings lessthan a number using awk

The awk below is supposed to count all the matching $5 strings and count how many $7 values is less than 20. I don't think I need the portion in bold as I do not need any decimal point or format, but can not seem to get the correct counts. Thank you :). file chr5 77316500 77316628 ... (6 Replies)
Discussion started by: cmccabe
6 Replies

4. Shell Programming and Scripting

awk command gives incorrect result?

Hi All, I am looking to filter out filesystems which are greter than a specific value. I use the command df -h | awk '$4 >=70.00 {print $4,$5}' But this results out as below, which also gives for lower values. 9% /u01 86% /home 8% /u01/data 82% /install 70% /u01/app Looks... (3 Replies)
Discussion started by: jjoy
3 Replies

5. Shell Programming and Scripting

awk sum giving incorrect value

cat T|awk -v format=$format '{ SUM += $1} END { printf format,SUM}' the file T has below data usghrt45tf:hrguat:/home/hrguat $ cat T -1363000.00123456789 -95000.00789456123 -986000.0045612378 -594000.0015978 -368939.54159753258415 -310259.0578945612 -133197.37123456789... (4 Replies)
Discussion started by: zulfi123786
4 Replies

6. Shell Programming and Scripting

awk file comparison, x lines after matching as output

Hello, I couldn't find anything on the Forum that would help me to solve this problem. Could any body help me process below data using awk? I have got two files: file1: Worker1: Thomas Position: Manager Department: Sales Salary: $5,000 Worker2: Jason Position: ... (5 Replies)
Discussion started by: killerbee
5 Replies

7. Shell Programming and Scripting

Merge lines in a file with Awk - incorrect output

Hi, I would like: FastEthernet0/0 is up, line protocol is up 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 output errors, 0 collisions, 0 interface resets Serial1/0:0 is up, line protocol is up 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 0... (14 Replies)
Discussion started by: mv652
14 Replies

8. Shell Programming and Scripting

awk should output if one input file doesnt have matching key

nawk -F, 'FNR==NR{a= $3 ;next} $2 in a{print $1, 'Person',$2, a}' OFS=, filea fileb Input filea Input fileb output i am getting : (2 Replies)
Discussion started by: pinnacle
2 Replies

9. Shell Programming and Scripting

Awk incorrect data.

I am using the following command: nawk -F"," 'NR==FNR {a=$1;next} a {print a,$1,$2,$3}' file1 file2 I am getting 40 records output. But when i import file1 and file2 in MS Access i get 140 records. And i know 140 is correct count. Appreciate your help on correcting the above script (5 Replies)
Discussion started by: pinnacle
5 Replies

10. Shell Programming and Scripting

Incorrect output using find command

I'm using the below command to list files older than 2 hours but it returns redundant output, am I missing something. # find . -mmin +120 -exec ls -l {} \; total 0 -rw-r--r-- 1 root system 0 Oct 13 09:52 test1 -rw-r--r-- 1 root system 0 Oct 13 09:52 test2 -rw-r--r-- 1 root ... (5 Replies)
Discussion started by: mbak
5 Replies
Login or Register to Ask a Question