8. digit mark (1, 2, 3 .. mark)

Source: Internet
Author: User

Use the numeric tag to specify a specific part of the old object. Only the keyword points at nth in old will be replaced. Each line starts from the beginning. n can be any number from 1 to 512.


For example,/11 will replace the keyword that appears at 11th in a row.

The following are some examples:

Replace the lowercase letter a that appears for the second time with the uppercase letter:

$ Sed's/a/A/2'employee.txt

101, John Doe, CEO

102, Jason Smith, IT MAnager

103, RajReddy, SysAdmin

104, AnandRAm, Developer

105, JaneMiller, SAles Manager


In this example, create a file that contains the following three rows:

$ Visubstitute-locate.txt

Locate command isused to locate files

Locate command usesdatabase to locate files

Locate command canalso use regex for searching


In the file you just created, replace the locate that appears for the second time with find:

$ Sed's/locate/find/2' substitute-locate.txt

Locate command isused to findfiles

Locate command usesdatabase to findfiles

Locate command canalso use regex for searching


Note: There is only one locate in the third row in the preceding example, so there is no change in the third row.




This article is from the "old studio" blog, please be sure to keep this source http://lduan.blog.51cto.com/5428084/1303225

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.