LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-14-2009, 11:46 AM   #1
bezoar
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
(Not so) Simple awk question.


df -k | sed 1d | awk '$5>90 {print}'

I have a work around but do NOT understand why the above will not pick up a file system that is 100% full. 90+ it finds. But not 100%.

My work around:
df -k | sed 1d | awk '$5>90 || $5 =="100%" {print}'

Any solution to my dilemma greatly appreciated.

Skiph
 
Old 09-14-2009, 12:16 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I believe the problem is that awk is doing the comparison as a string and not a numeric operator. And in strings "10" is less than "9". It works if you remove the % sign from the input, because awk treats "stand-alone" numbers numerically.

I'm not sure what the best way to work around it would be.

Last edited by David the H.; 09-14-2009 at 12:19 PM. Reason: minor rewording
 
Old 09-15-2009, 08:27 PM   #3
bezoar
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by David the H. View Post
I believe the problem is that awk is doing the comparison as a string and not a numeric operator. And in strings "10" is less than "9". It works if you remove the % sign from the input, because awk treats "stand-alone" numbers numerically.

I'm not sure what the best way to work around it would be.
I appreciate the response. I will look at this from a string rather than a numeric view.

Again, thanks for your efforts.

Skiph

Last edited by bezoar; 09-15-2009 at 08:30 PM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple awk script question adam_blackice Programming 9 09-03-2007 02:23 PM
simple awk question getline coldy78 Programming 3 04-20-2007 11:39 PM
simple awk question mr_scary Linux - General 3 02-23-2007 06:37 PM
Simple question about sed or awk setianusa Programming 2 09-16-2005 03:57 PM
Simple bash/awk/sed scripting question R00ts Programming 4 04-16-2005 02:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration