You're replying to a comment by Peter Krumins.

October 07, 2008, 06:20

Sydney, thanks for your question.

I see a couple of mistakes here. First of all you are using grep twice! Awk can do what grep does itself with the /.../ regex pattern matching.

Here is what I came up with (works in GNU Awk only!):

df -h | awk '/dev/ { if (strtonum($5) >= 20) { print $NF ": " $(NF-1) } }'

And this one works in all Awk's:

df -h | awk '/dev/ {
 if (match($5, /^[0-9]+/)) {
  usage = substr($5, RSTART, RLENGTH)
  if (usage >= 20) {
   print $NF ": " $(NF-1)
  }
 }
}'

Hope it helps.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "cdrom_92": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.