shell for 循环 参考 Linux下Shell的for循环语句、Shell逐行读取文件的3种方法
for循环语法
for var in item1 item2 ... itemN
do
command
done
for循环 路径查找
在/mx文件夹有文件 check_list md5result test_for.sh test.sh
语法:for file in filepath/*
filepath2=/mx/*
for file in ${filepath2}
do echo ${file}
done
输出如下
/mx/check_list
/mx/md5result
/mx/test_for.sh
/mx/test.sh
语法:for file in `find filepath`
filepath=/mx
for file in `find ${filepath}`
do echo ${file}
done
for循环输出如下
/mx
/mx/check_list
/mx/md5result
/mx/test.sh