#/bin/bash 
function recursive_list_dir(){
    for file_or_dir in `ls $1`
    do
        if [ -d $1"/"$file_or_dir ]
        then
            recursive_list_dir $1"/"$file_or_dir 
        else
            file=$1"/"$file_or_dir 
            echo $file
        fi
    done
}
lm_traverse_dir $1

需要注意,传参数是文件名,结尾不要加"/"

Logo

更多推荐