shell指令碼獲取一個目錄、及其子目錄下的所有檔案
阿新 • • 發佈:2019-02-19
#!/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";