#!/bin/sh#usage(){ printf "input oldDIr number" read USERNAME1 echo $USERNAME1 USERNAME1_TIMES=$USERNAME1 printf "input newDir number" read USERNAME2 USERNAME2_TIMES=$USERNAME2 echo $USERNAME2# for i in `seq 3`# do# sleep 1s# echo ${i}"s"# done clear}return_oldDir(){ #USERNAME1=315640 sum=$USERNAME1 # echo $sum #315640,313642//956/912/824/ idDir="" for((i=0; i<3; i++)) do temp=`expr $sum % 999` # echo $temp sum=`expr $sum + $temp` # echo $sum temp=`expr $temp + 1` idDir=${idDir}${temp}"/" done #echo "the oldDir is:" # echo $idDir #return idDir} return_newDir(){ sum=$USERNAME1 #;//315640,313642//956/912/824/ for((i=0; i<3; i++)) do temp=`expr $sum % 999` sum=`expr $sum / 999` newidDir=${temp}"/"${newidDir} done #echo "the newDir is:" #echo $newidDir #return newidDir;}usagefor((j=`expr $USERNAME1_TIMES - 0` ;j<`expr $USERNAME2_TIMES - 0`; j++))doreturn_oldDir#echo $idDir return_newDir#echo $newidDirsource_old=${idDir}"*"source_old_exit=${idDir%%/}source_new=${newidDir%%/}#echo $source_new#echo $source_creat_dirif [ -d $source_old_exit ]thenif [ -d $source_new ]thenecho "new dir exit"elseecho "new dir not exit can makedir"mkdir -p $source_newecho ${source_new}"create"chmod 777 $source_newficp -i $source_old $source_newelseecho "old dir not exit"fiecho $source_old#echo $source_newnewidDir=""USERNAME1=`expr $USERNAME1 + 1`USERNAME2=`expr $USERNAME2 + 1`#echo $USERNAME1#echo $USERNAME2doneexit 0
可惜了C++版本让我弄丢了 恶心