"Issue"... The command is doing what is actually instructed to.
Given this mbox format file:
From: [email protected] #identifies the beginning of the first mail
...
Subject: crcheck.sh #identifies the beginning of the mail body
...
MYVARIABLE="123"
...
From: [email protected] #identifies the beginning of the next mail
...
Subject: crcheck.sh #identifies the beginning of the mail body
...
From: [email protected] #identifies the beginning of next mail
...
Subject: crcheck.sh #identifies the beginning of the mail body
EVILVARIABLE="0.00" #just to mention a value that would cause division by zero errors and crash my main script.
...
From: [email protected] #identifies the beginning of the next mail
...
I need to select all lines between a valid Subject: and the next From:, but the From: preceiding the Subject line should be the $GOODSENDER one.
The code I'm running:
GOODSUBJECT="crcheck.sh"
GOODSENDER="[email protected]"
cat $MBOX |awk "/Subject\: $GOODSUBJECT$/{a=1}/From\:\ $GOODSENDER /{print;a=0}a"|grep $i\=\"
Outputs:
MYVARIABLE="123"
EVILVARIABLE="0.00"
Expected output:
MYVARIABLE="123"
The command is doing what it's instructed to, as those lines are acutally between two of the lines I set as patterns for awk.
But how can I adjust it to have this desidered behaviour?
"crcheck.sh"
subject in your input. Will you update the input?