Find and replace text in a file between range of lines using sed

前端 未结 2 459
闹比i
闹比i 2020-12-16 15:57

I have a big text file (URL.txt) and I wish to perform the following using a single sed command:

  1. Find and replace text \'google\' with \'facebook\'

2条回答
  •  别那么骄傲
    2020-12-16 16:29

    You can use sed addresses:

    sed '19,33s/google/facebook/g' file
    

    This will run the substitution on lines between and including 19 and 33.

    The form of a sed command is as follows:

    [address[,address]]function[arguments]
    

    Where 19,33 is the addreses,
    substitute is function
    and global is the argument

提交回复
热议问题