Shell script implements bulk replacement file content _linux Shell

Source: Internet
Author: User

Today colleagues found that the internal server's hard disk space is not enough, there are many backups, I can not delete, and found a 320g hard disk mounted, want to later the shell script backup to the new hard disk, to make room for the old hard drive, the original backup path is/data/onlinesqlbak/ , the new backup path is/disk2/onlinesqlbak/, I find the next backup shell script, this look scared to death of a person, at least 10-20 backup shell to change, who called me a lazy person think about finishing, well come to see my solution.

System: CentOS 5.x

1. Confirm that there are those scripts to change

Copy Code code as follows:

Find ~/soft_shell/-name "*" |xargs grep "/data/onlinesqlbak/"

2. Replace the content in the script
Copy Code code as follows:

Find ~/soft_shell/-type f-path "*.sh" |xargs sed-i ' s:/data/onlinesqlbak/:/disk2/onlinesqlbak/:g '

3. Verify
Copy Code code as follows:

Find ~/soft_shell/-name "*" |xargs grep "/disk2/onlinesqlbak/"

All right, it's going to be a pretty big deal soon.

Related Article

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.