<pre name="code" class="python">#!/bin/sh
list_dir(){
for file in $1/*
do
if [ -d $file ]
then
echo $file
list_dir $file
elif [ -f $file ]
then
echo $file
fi
done
}
if [ $# = 0 ]
then
echo at least 1 arguments
elif [ ! -d $1 ]
then
echo not a directory
else
cd "$1"
p=$(pwd)
list_dir "$p"
# cd -
# ./Pre
fi
bash 递归遍历文件夹
最新推荐文章于 2023-06-14 19:58:24 发布