How to replace keywords with multiple files in linux

Source: Internet
Author: User

In linux, there are only two methods for replacing keywords with multiple files: The Mahuinan method, the Sumly method, and the 30 t method: 1. Mahuinan method: You can use the sed command to replace strings in multiple files in batches. Sed-I "s/original string/New String/g" 'grep original string-rl directory 'For example: replace/home/gbase/table_space in the. txt file under/root/tm/directory with/home/hj/gbase/table_space and run the following command: sed-I "s/home \/gbase \/table_space/\/home \/hj \/gbase \/table_space/g" 'grep home \/gbase \/table_space-rl /root/tm /*. txt 'This is currently the simplest string replacement command in linux! The specific format of www.2cto.com is as follows: sed-I "s/oldString/newString/g" 'grep oldString-rl/path' instance code: sed-I "s/size/Sun/month/g" 'grep size-rl/usr/aa 'sed-I "s/size/Sun/month/g "' grep size-rl. /'II. Run the command in the Sumly method: perl-p-I-e "s/China/Sumly/g"/www /*. htm/www /*. in txt, replace "China" in all htm and txt files in the www folder with "Sumly". 3. Execute the following command in 30 t mode: www.2cto.com perl-pi-e's | baidu | 30T | g''find/www-type F' indicates all the files in the www folder, regardless of the extension, replace all "baidu" with "30T" // sed-I "s/JSON/JSONYH/g" 'grep JSON-rl .. /src 'sed-I "s/CONFIG: pad/CONFIG: pad_tmp/g" 'grep CONFIG: pad-rl. /'gameconfigpaywindow author tianmaotalk

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.