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

Viewed 18394

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' between line numbers 19 and 33.

  2. Display the output on the terminal without altering the original file.

2 Answers

the above answer ALMOST worked for me on Mac OSX.

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

worked perfectly without braces.

sed '19,$s/google/facebook/' file

works until the end of the file as well.

Related