shell 递归遍历文件夹文件

#!/bin/bash
dirpath=$1
function read_dir() {
    for file in `ls $1`
    do  
        #echo "$1:"$1 
        if [ -d $1/$file ];then
            cd $1/$file
            read_dir $1"/"$file
            cd -
        else
            echo `pwd`/$file
        fi
    done
}
read_dir $dirpath

  

猜你喜欢

转载自www.cnblogs.com/luckygxf/p/12312047.html