O'Reilly logo
  • Raffi Mohammed thinks this is interesting:

/Operator$/{
N
s/Owner and Operator\nGuide/Installation Guide/
}

From

Cover of sed & awk, 2nd Edition

Note

Not sure why it was stated \n cannot be used to insert in the replacement. That worked fine on an ubuntu server just fine.

cat sample.txt Consult Section 3.1 in the Owner and Operator Guide for a description of the tape drives available on your system.

sed '/Operator$/{N; s/Owner and Operator\nGuide/Installation Guide\n/; }' sample.txt Consult Section 3.1 in the Installation Guide for a description of the tape drives available on your system.

sed '/Operator$/{N; s/Owner and Operator\nGuide/Installation Guide/; }' sample.txt Consult Section 3.1 in the Installation Guide for a description of the tape drives available on your system.

$ uname -a Linux ip-172-31-38-98 4.4.0-1063-aws #72-Ubun...