shell脚本实现遍历文件夹查找指定文件
shell 脚本文件夹递归
·
#!/bin/bash
# 递归文件夹,查询zip文件
function readZipFile ()
{
for file in `ls $1`
do
# -d表示这个是 文件夹
if [ -d $1"/"$file ]
then
# 是文件夹就递归
readZipFile $1"/"$file
else
# 判断是否是zip文件
if echo $1"/"$file | grep -q -E '.zip'
then
# 输出文件的地址
echo $1"/"$file
fi
fi
done
}
path="/home/"
readZipFile $path
更多推荐
已为社区贡献2条内容
所有评论(0)