How to grep directories

How to grep directories has reached above 80% from the df output using basin grep command.below are the steps i have used
df -h > date.ksh
grep "%" date.ksh >space.ksh
cut -c 40-44,45-80 space.ksh > %.ksh
grep "[80-10][0]%" %.ksh
see the output after above cmd
$ grep "[80-10][0]%" %.ksh
100% /opt/tivoli/tsm
80% /prod/users/edw
10% /prod/home01/sand
I am not able to see the 81%,.......89% etc..how can i see them using grep

Questions by hari.pardha   answers by hari.pardha

Showing Answers 1 - 30 of 30 Answers

Santosh Nemani

  • Mar 20th, 2012
 

#!/bin/ksh +x


df -kl|grep "<8[0-9]%>" > dfout.log
df -kl|grep "<9[0-9]%>" >> dfout.log
df -kl|grep "100%" >> dfout.log

Tabrejkhan

  • Sep 3rd, 2012
 

$ df -k|grep "1[0-9]%"
O/p:
2031440 342300 1584284 18% /
3047184 392216 2497684 14% /opt
190403 31064 149509 18% /osmf/mgmt/scheduler
3047184 391464 2498436 14% /var
/dev/cciss/c0d0p1 101086 15970 79897 17% /boot

  Was this answer useful?  Yes

Vinil Mehts

  • Aug 26th, 2014
 

You can use awk to check the % free space. Example stated as follows in UNIX.

Code
  1. df -k|

  2. awk

  3. {

  4. if $5>80;


  5.  }

  Was this answer useful?  Yes

Rohit

  • Feb 18th, 2015
 

df -h | awk {print $5 " " $6} | grep -vi use |grep ^[8|9][0-9]|100

  Was this answer useful?  Yes

abhinav

  • Jan 19th, 2016
 

grep -r string dirname.

If you want to search in current directory then
grep -r string .

  Was this answer useful?  Yes

Raans

  • Sep 6th, 2016
 


for a in df -h|awk {print($5" "$6)}`
do
b=`echo $a|awk -F"%" {print ($1)}`

if [$b -gt 80]
then
echo $a
fi
done

  Was this answer useful?  Yes

Anupam Kumar

  • Nov 2nd, 2016
 

Here it is-

Code
  1. ls -l | grep ^d

  Was this answer useful?  Yes

suman chakraborty

  • Nov 8th, 2016
 

df -k | tr -s " "|awk {FS=" ";}{if ( substr($5,1,2) >= 80 ) print $1;}

  Was this answer useful?  Yes

Asish

  • Dec 28th, 2017
 

df -h | tr % /32 | awk $5 > 80

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions