讀取檔案迴圈處理的兩種方法

BTxigua發表於2008-03-18

 

方法1:

cat $TEMP_DIR/disk_info | grep -v '^#' | while read line
do
item1=$(echo $line | awk -F ',' '{print $1}')
item2=$(echo $line | awk -F ',' '{print $2}')
item3=$(echo $line | awk -F ',' '{print $3}')
item4=$(echo $line | awk -F ',' '{print $4}' |awk -F '%' '{print $1}')
item5=$(echo $line | awk -F ',' '{print $5}')
item6=$(echo $line | awk -F ',' '{print $6}')
item7=$(echo $line | awk -F ',' '{print $7}')
if [ "$item4" -gt "$DISK_VALUE" ]; then
    diskflag=1
    echo "LOG-Warnning: `date +%Y'-'%m'-'%d' '%H':'%M':'%S`, The file system $item7 is up to ${item4}%.Please c
heck!!"
    sendmessage "Host:$HOSTIP The file system $item7 is up to ${item4}%.Please check!"
fi
done

 

 

方法2:

for user in $(cat /home/pubuser/user.list)
do
/bin/chuser groups=staff $user
done

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10867315/viewspace-210635/,如需轉載,請註明出處,否則將追究法律責任。

相關文章