- 论坛徽章:
- 0
|
如何将awk中的域 转换成整形的数据赋植给一个变量
谢谢
我想写个shell来监控系统的quota 当某个user的quota 达到80%, 90% ,95%时发mai给用户提醒!
怎么做啊!
repquota -a|grep -v +|grep -v root|grep - > quotaall.txt
awk '{if ($3>int($4*0. )print}' quotaall.txt > overquota.txt 先将>80%的获取到
awk '{printf ("%-15s %d %d %d %d\n",$1,$3,$4*0.8,$4*0.9-$3,$4*0.95-$3) }' over
quota.txt > overquota1.txt
awk '{printf ("%s\n",$1) }' overquota1.txt >user.txt
for uid in `cat user.txt`
do
grep $uid overquota1.txt > tmp.txt
flag=8
if awk $4 overquota1.txt > 0 ;then $flag=9 这里如何获取到第4列并且比较
if awk $5 overquota1.txt > 0 ;then $flag=10
case $flag in

mailx -s mailquota $uid < over80.log
echo over80.log
;;
9)
mailx -s mailquota $uid < over90.log
echo over90.log
;;
10)
mailx -s mailquota $uid < over95.log
echo over95.log
;;
esac
done |
|