linux shell之do done及for 迴圈指令碼

wisdomone1發表於2013-06-25

---for迴圈的shell指令碼,迴圈顯示某個目錄的所有檔名稱
-bash-3.2$ more cycle.sh
filelist=`ls -l|awk {'print $9'}`
for file in $filelist
do
 if [ -f $file ]
 then
    echo "echo ${file}"
 fi
done

---執行cycle.sh迴圈指令碼
-bash-3.2$ . ./cycle.sh
echo afiedt.buf
echo all.sh
echo autosu.sh
echo cycle.sh
echo deletejob.sql
echo do_do.sh
echo donew.sh
echo do.sh
echo exit
echo haha.txt
echo manual.html
echo maxsize.sh
echo new.sh
echo nohup.out
echo rmanlog.log
echo sed
echo select
echo spfilebak
echo spool
echo sqlplustoshell.sh
echo startupdb.sh
echo startup.sh
echo tbs_mod2.dbf
echo temp02.dbf
echo test.sh
echo testsingle.ora
echo true.sh
echo zidong.sh
echo zidong.sh.orig

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

相關文章