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.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.