I can print everything between two patterns with this awk command:
awk '/'$1'/{a=1} a; /PATTERN2/{a=0}' ~/the/path/to/file.txt
What I need is to print everything between and include PATTERN1 and everything before PATTERN2 (which is always a line that starts with #
.
Actually the patterns are hashtags like #france
and #germany
.
For example the file contains:
#france
France is a European country.
It's capital city is Paris.
One of its biggest cities is Lyon.
#germany
Germany is a European country.
It's capital city is Berlin.
One of its biggest cities is Munich.
What I want to be printed after calling #france:
#france
France is a European country.
It's capital city is Paris.
One of its biggest cities is Lyon.
Also it would be great if I can show the pattern in another color like blue or red.