Linux之shell脚本遍历文件夹下所有文件

#!/bin/bash

function ergodic(){

for file in ` ls $1`

do                

    if [ -d $1"/"$file] #如果 file存在且是一个目录则为真                

    then                       ergodic $1"/"$file                

  else                       local path=$1"/"$file #得到文件的完整的目录                      

                 local name=$file       #得到文件的名字                                   

   fi

done }

INIT_PATH="/home"

ergodic $INIT_PATH

posted on 2015-03-05 16:05  箫轩  阅读(10026)  评论(0编辑  收藏  举报

导航