Print lines between 2 words
Posted on 24 Aug 2020
You may arrive in a situation where you may want to "extract" out text between two words. For example to view the latest changelog (where x.x.x
is the latest version) in a CHANGELOG.md file.
Using sed
sed
sed -e '1d;$d'
removes the first & last line.
Using awk
awk
awk 'NR>2 {print last} {last=$0}'
removes the first & last line.
NOTE:
NR
means which Line number is being processed
Resources
Last updated