当前位置: > shell编程 >

shell脚本获取一个目录、及其子目录下的所有文件

时间:2016-10-21 22:06来源:linux.it.net.cn 作者:IT
  1. #!/bin/sh  
  2. read -p "input path:" FilePath;  
  3. function getAllFiles()  
  4. {  
  5.         fileList=`ls $FilePath`;  
  6.         for fileName in $fileList;  
  7.         do  
  8.            #if test -f $fileName; then  
  9.            if [-f $fileName ];then  
  10.               echo $fileName;  
  11.            elif test -d $fileName; then  
  12.               cd $fileName;  
  13.               FilePath=`pwd`;  
  14.               getAllFiles;  
  15.               cd ..;  
  16.            else  
  17.               echo "$FilePath is a invalid path";  
  18.            fi  
  19.         done  
  20. }  
  21. cd $FilePath;  
  22. getAllFiles;  
  23. echo "DONE";  


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容