标签:
#!/bin/sh PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin LANG=zh_CN.GB18030 export PATH LANG ANALYZER_HOME=$(cd "$(dirname "$0")"; pwd) cd $ANALYZER_HOME declare -a fileArr echo $1", "$2 function listDirFile() { #fileArr=() i=1 for file in `ls $1|grep -E "\.txt$"` do if [ -d $1"/"$file ] then listDirFile $1"/"$file else f=$1"/"$file doing=$1"/"$file.doing echo $f" -> "$doing mv -f $f $doing fileArr[$i]=$doing i=`expr $i + 1` if [ "$i" -gt "$2" ] then #echo $2" break "$1 break fi fi done } listDirFile $* i=1 for data in ${fileArr[@]} do echo $i": "${data/.doing/} #mv -f ${data} ${data}.done mv -f $data `echo $data | sed ‘s/doing$/done/‘` i=`expr $i + 1` done
执行
# readFile.sh 目录 数量 readFile.sh /home/user/files 2
标签:
原文地址:http://my.oschina.net/u/565351/blog/378727