shell脚本获取一个目录、及其子目录下的所有文件
时间:2016-10-21 22:06 来源:linux.it.net.cn 作者:IT
-
#!/bin/sh
-
read -p "input path:" FilePath;
-
function getAllFiles()
-
{
-
fileList=`ls $FilePath`;
-
for fileName in $fileList;
-
do
-
#if test -f $fileName; then
-
if [-f $fileName ];then
-
echo $fileName;
-
elif test -d $fileName; then
-
cd $fileName;
-
FilePath=`pwd`;
-
getAllFiles;
-
cd ..;
-
else
-
echo "$FilePath is a invalid path";
-
fi
-
done
-
}
-
cd $FilePath;
-
getAllFiles;
-
echo "DONE";
(责任编辑:IT)
(责任编辑:IT) |