1#!/bin/Bash2 Echo "This is a timed script, the main function is to traverse all the files under the folder and store it in an array, manipulate the files in the data, move one to the specified directory, and delete the original file. "3j=04 for file inch/home/liuren/liuren_test/*5 Do6 filenum= ' ls-l |grep "^-" |wc-l '7 filenamelist[j]= $file8 j= ' expr $j +1 '9 DoneTen echo ${filenamelist[@]} One For ((i=0;i<filenum;i++)); A Do - echo ' file list under this folder is as follows: ' - echo ${filenamelist[$i]} the echo ' starts copying files to the specified directory ' - cp-r ${filenamelist[$i]}/home/liuren/liuren_test2/ - echo ${filenamelist[$i]} ' file copy succeeded! ' - rm-r ${filenamelist[$i]} + Echo ' Delete copy successful ' ${filenamelist[$i]} ' file! ' - Echo ' >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>> Execute successfully-rest for 5 seconds, then continue execution <<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<< ' + Sleep 5 A Done
This is a timed script, the main function is to traverse all the files under the folder and store them in an array, manipulate the files in the data, move one to the specified directory, and delete the original files.