Answers for "grep show lines between matches"

0

grep lines between two patterns in unix

$ sed -n '/aaa/,/cdn/p' file
aaa
b12
cdn
$ sed -n '/zdk/,/dke/p' file
zdk
aaa
b12
cdn
dke
Posted by: Guest on June-18-2020
0

grep show lines between matches

Just use following structure to get result between two different patterns:
sed -n '/^pattern1/,/^pattern2/p;/^pattern2/q' file.txt
Posted by: Guest on December-03-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language