bash(3):遍历文件

#!/bin/bash
function getdir(){
    for element in `ls $1`
    do  
        dir_or_file=$1"/"$element
        if [ -d $dir_or_file ]
        then 
            getdir $dir_or_file
        else
            echo $dir_or_file
        fi  
    done
}
root_dir="/home/test"
getdir $root_dir

 

posted on 2017-07-06 15:25  细雨微光  阅读(1110)  评论(0)    收藏  举报