I have data in a text file something like below.
server volume available total used percent-used percent-vol-space --------------- -------------------- --------- ------- ----- ------------ ---------------------- TEMPSERVER TEMP_root 972.4MB 972.8MB 388KB 5% 5% TEMPSERVER TEMPVOL01 2.59TB 5.13TB 2.55TB 54% 10% TEMPSERVER TEMPVOL02 2.26TB 4.10TB 1.53TB 50% 10% TEMPSERVER TEMPVOL02_Clone 2.26TB 4.10TB 1.57TB 50% 10% TEMPSERVER TEMPVOL03 1.79TB 3.88TB 2.10TB 63% 20% TEMPSERVER TEMPVOL03_Clone 2.26TB 4.10TB 1.79TB 50% 10% TEMPSERVER TEMPVOL04 3.32TB 4.30TB 807.3GB 30% 10% 22 entries were displayed.
Now i want to print each line if the value in column 6 OR 7 are greater than 90%. How do i do this?
Answer
awk 'NR > 2 && (0+$6 > 90 || 0+$7 > 90)' <file
This would read the data line by line and whenever a line has a number larger than 90 in the 6th or 7th field, it will be printed. We skip the first two header lines with NR > 2
and we add zero to the values in column six and seven to force a conversion to a number (the %
sign in the data will be dropped by this) before testing them against 90.