for / do / done循环如何在这个脚本中工作?

时间:2015-02-20 18:04:38

标签: shell unix

oracle@hostname:/home/oracle# cat /home/oracle/scripts/nc_profile.sh
for DB in `cat /home/oracle/SCRIPTS/lib/db_prod.lst`
do
echo "=========================================" > /home/oracle/notcomlog
echo "===============" >> /home/oracle/ncomply.log
echo $DB >> /home/oracle/ncomply.log
echo "===============" >> /home/oracle/ncomply.log
echo $DB >> /home/oracle/notcomlog
/home/oracle/scripts/nc_profile.sql $DB >> /home/oracle/ncomply.log
cat /home/oracle/ncomply.log | awk '{ print $1 "," $2}' >> /home/oracle/notcomlog
echo "=========================================" >> /home/oracle/notcomlog
mail -s  "Non compliant profile as per WG policy $DB"myemail@emailhost.com < home/oracle/ncomply.log
rm /home/oracle/notcomlog
rm /home/oracle/ncomply.log
done

1 个答案:

答案 0 :(得分:0)

bash for循环,遍历每个$IFS。默认情况下,该空白区域。

因此/home/oracle/SCRIPTS/lib/db_prod.lst中的每一行 - $DB都设置为该行的内容。然后循环运行到done