bash - list users with quota over specified value in linux -
i have been spending lot of time trying create quota check script , have not gotten results need.
i using loop iterate awk command search value greater 3000000.
base of command output quota:
for in `awk '{print $2}' /etc/userdomains | grep -v "nobody" | sort -u` quota -v -u $i done
output per iteration:
disk quotas user exampleuser (uid 2599): filesystem blocks quota limit grace files quota limit grace /dev/sda1 8 0 0 10 0 0 /dev/sdb1 0 0 0 0 0 0 /dev/sdc1 57792 0 0 2511 0 0 /dev/sdd1 0 0 0 0 0 0 /dev/sde1 0 0 0 0 0 0
i intend pipe awk command print line 1; field 5 , line equal or greater 3; field 2 if field 2 greater 50000
so wanted output be:
exampleuser 57792
or
exampleuser 57792
so far cannot these results using different methods in awk.
here last 2 tries (based off value greater 3000000):
for in `awk '{print $2}' /etc/userdomains | grep -v "nobody" | sort -u` quota -v -u $i | awk '{ if ($2 >= 3000000) print $0 ; else;}' done
output:
disk quotas user bforrest (uid 2108): filesystem blocks quota limit grace files quota limit grace disk quotas user bible (uid 500): filesystem blocks quota limit grace files quota limit grace /dev/sdc1 12230716 0 0 10168 0 0 disk quotas user bigbeau (uid 1608): filesystem blocks quota limit grace files quota limit grace disk quotas user bilgem (uid 3299): filesystem blocks quota limit grace files quota limit grace disk quotas user billbell (uid 2872): filesystem blocks quota limit grace files quota limit grace disk quotas user biosalus (uid 3215): filesystem blocks quota limit grace files quota limit grace disk quotas user bkeating (uid 1104): filesystem blocks quota limit grace files quota limit grace /dev/sdc1 3106480 0 0 9636 0 0 disk quotas user blaaraba (uid 2931): filesystem blocks quota limit grace files quota limit grace disk quotas user blackbird (uid 1666): filesystem blocks quota limit grace files quota limit grace
another one:
for in `awk '{print $2}' /etc/userdomains | grep -v "nobody" | sort -u` quota -v -u $i \ | awk '{ if (nr >= 3 && $2 >= 3000000) print $0 ; else;}' \ | cut -d "*" -f1 done
output:
/dev/sdc1 55948456 0 0 45806 0 0 /dev/sdd1 91428904 0 0 97739 0 0 /dev/sdd1 512000 /dev/sdc1 60275820 0 0 10594 0 0 /dev/sdb1 512460 /dev/sdb1 93819732 0 0 47951 0 0 /dev/sdd1 527613532 0 0 11935 0 0 /dev/sdd1 56922524 0 0 60761 0 0 /dev/sdc1 307664 /dev/sdb1 65851960 0 0 257999 0 0
maybe method totally off. thoughts on this?
update:
found better command (repquota -a
) report quota. more consistent since doesn't vary depending on files located:
for in `awk '{print $2}' /etc/userdomains | grep -v "nobody" | sort -u` repquota -a | awk {'print $1 " " $3'} | grep -w $i \ | awk '{if ($2 >= 5000000) print $0 ; else;}' done
output:
a4fundjs 55948456 actifeve 12535196 aepromo 13224160
for original input
awk 'nr==1{print $5} nr>2 && $2>50000 {print $2}'
will print
exampleuser 57792
Comments
Post a Comment