Example of changing content 123 in one file to 456 in Linux

Source: Internet
Author: User
Keywords Linux
Tags content example file linux modified nginx nginx.conf root

Today we are going to introduce Linux to the example of 123 to 456 in a file, this method is more widely used, especially for the contents of the file changes, the following is a detailed understanding of the two methods of modification:

Modify Method 1

#sed ' s/123/456/g ' file.txt > File.txt.new

#mv-F file.txt.new file.txt

Example:

[root@localhost conf]# sed ' s/123/456/g ' nginx.conf > Nginx.conf.new
[Root@localhost conf]# mv-f nginx.conf.new nginx.conf

Modify Method 2

Make modifications through the Find string feature in the VI editor

[Root@localhost conf]# VI nginx.conf

Enter command:

:%s/123/456/g

: Wq

After you save the exit.

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.