I have a file results.txt
which is like:
a.txt
{some data}
success!!
b.txt
{some data}
success!!
c.txt
{some data}
error!!
I want to extract data from it. I want an output like:
a.txt: success
b.txt: success
c.txt: error
The problem is that the {some data}
part can be arbitrarily long.
How can this be done?
awk:
BEGIN {
state=0
}
state==0 && /.txt$/ {
filename=$0
state=1
next
}
state==1 && /!!$/ {
print filename ": " gensub(/!!$/, "", $0)
state=0
next
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With