I need to get something like this
#Batch Job - AB1234
texts
texts
texts
texts
texts
#--------
I used
awk '/#Batch Job.*AB1234/,/#--.*/' filename
and i went well.
But then when I tried to parameterize the AB1234, using this script, I failed. Help?
BATCHJOBNAME=AB1234
awk -v batchjobname=$BATCHJOBNAME '
/#Batch.*/ { f=1 ; m=0 ; res="" }
f { res = res $0 ORS }
f && /Job.*/ && index($2,batchjobname) > 0 { m=1 ;}
/<#--.*>/ { f=0 ; if (m) print res ; }
' filename
awk -v batchjobname=AB1234 '$0~batchjobname,/#--.*/' filename
? – FloHimself Jun 9 at 7:55