#!/bin/shpath=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbinlang=zh_cn. gb18030export path langanalyzer_home=$ (cd "$ (dirname ") "; pwd) cd $ANALYZER _ Homedeclare -a filearrecho $1 ", " $2function 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 " -> " $DOINGMV -f $f $doing filearr[$i]= $doing i= ' EXPR  $i + 1 ' if [ $i -gt "$" ] then #echo $2 " break " $1 break fi fi done}listDirFile $*i=1for 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
Perform
# readfile.sh Number of directories Readfile.sh/home/user/files 2
Every time you read a specified directory, a specified number of file shell scripts