Do you know why no one answered you? Don’t you know how to use pipes? ......|grep -A......|grep -B...... Of course, you need to completely implement the function you mentioned, perl/awk, but obviously You need to be very familiar with regular expressions and related grammar to write it yourself. You may not be able to figure it out for a while. Regular tool learning order (increasing complexity): grep/egrep/fgrep/ack -> sed/ed/vim -> awk/perl
Do you know why no one answered you?
Don’t you know how to use pipes?
......|grep -A......|grep -B......
Of course, you need to completely implement the function you mentioned, perl/awk, but obviously You need to be very familiar with regular expressions and related grammar to write it yourself. You may not be able to figure it out for a while.
Regular tool learning order (increasing complexity):
grep/egrep/fgrep/ack ->
sed/ed/vim ->
awk/perl