Bulk Replace file contents under Linux

Source: Internet
Author: User

1. Ready-made information on the Internet

Format: Sed-i "s/lookup field/replace field/g" ' grep lookup field-rl path '

Linux SED Bulk replaces strings in multiple files

Sed-i "s/oldstring/newstring/g" ' grep oldstring-rl yourdir '

For example: Replace the www.admin99.net in all files under/home to Admin99.net

Sed-i "s/www.admin99.net/admin99.net/g" ' grep www.admin99.net-rl/home '

Exp:sed-i "s/shabi/$/g" ' grep shabi-rl./'

2, self-added additional

2.1 Replace the text "garden" in file 1.txt with "Mirgarden"

# sed-i "s/garden/mirgarden/g" 1.txt//sed-i very simple

2.2 Replace "garden" in all files in the current directory with "Mirgarden"

# # Sed-i "s/garden/mirgarden/g" ' ls '//is actually the LS out of multiple filenames

Bulk Replace file contents under Linux

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.