1. 程式人生 > >linux迴圈遍歷資料夾下所有檔案

linux迴圈遍歷資料夾下所有檔案

demofun(){
    for file in `ls $1`
    do
        if test -f $file
        then
            echo "file:  $file"
        elif test -d $file
        then
            echo "path: $file"
        fi
    done
}

path="/home/lwang/Desktop/wujuan"
demofun $path