how can I find lines between two words with 3 lines before START_WORD in sed or grep or ...
for example output from a command is:
my name is
Mansour
and I confuse to
use sed
or grep for
piping my command output
to get
my ideal output
and I want my out after piping the command with sed or grep on START_WORD=command and END_WORD=ideal:
and I confuse to
use sed
or grep for
piping my command output
to get
my ideal output
grep -Pzo '(?s)\n\K([^\n]*\n){3}[^\n]*command[^\n]*\n.*?\n[^\n]*ideal[^\n]*(?=\n)' file.txt
..if the question is reopened, let me know..i will put it as an answer with details..