I have a big text file (URL.txt) and I wish to perform the following using a single sed command:
Find and replace text 'google' with 'facebook' between line numbers 19 and 33.
Display the output on the terminal without altering the original file.
I have a big text file (URL.txt) and I wish to perform the following using a single sed command:
Find and replace text 'google' with 'facebook' between line numbers 19 and 33.
Display the output on the terminal without altering the original file.
You can use SED's range selector for that:
sed '19,33{s/google/facebook/}' file
This will run the substitution on lines between 19 (exclusive) and 33 (inclusive)
Note this will only replace the first occurrence of google
on each line, you can use the g
-modifier to change this behavior:
s/google/facebook/g