In linux shell, we sometimes need to copy a file in batches. The same principle applies to batch users. The knowledge used: test or [: can be used to compare the arithmetic comparison-equal eq-ne-gt greater than-ge is greater than or equal to-lt is less than-le is less than or equal! Test whether-d is directory-f is set-group-id of file-g, whether the-r file is readable, and whether the file is blank file, if the file size is not zero, the result is true. -U file's set-user-id is set-w file can write-x file can be executed to get the parameters passed during runtime $1, $2 .... $ n: 1st, 2nd .... The Nth parameter. (Excluding the file name) $ @ is extended to "$1" "$2 "... "$ n" $ # number of parameters if statement format: if conditionthen statementselse statementsfi while statement format: while conditiondo statementsdone let's look at the Code directly. (Because arithmetic calculation is used. I am using bash shell. Run successfully in ubunut12.04 .) [Plain] #/bin/bash argc =$ # if [$ argc-lt 2] then echo "Please input two parameters, for the files to be copied and the number of times "exit 0 fi file = $1 count = $2 left =$ {file %. *} # retrieve the file name. For example, the final result of a.tar.gz is a.tar right =$ {file ##*.} # To obtain the file suffix. For example, the result of a.tar.gz is gz I = 0 if [-f "$ file"] # To determine whether the file exists. Then while [$ I-le $ count] do cp $ file "$ left $ I. $ right "#" $ left $ I. $ right "combine the new file name let" I = $ I + 1 "# Add a value for I to done else echo" $ file is not exist \ n "fi Source: http://blog.csdn.net/rentiansheng/article/details/8851684