On 12/20/22, David <bouncingc...@gmail.com> wrote: > On Tue, 20 Dec 2022 at 22:04, David <bouncingc...@gmail.com> wrote: >> On Tue, 20 Dec 2022 at 22:02, David <bouncingc...@gmail.com> wrote: > >> > $ echo -e '100:CD001\n200:CD001' | awk 'BEGIN { FS=":" } /CD001/ && >> > NR==1 { print $1 - 50 }' >> > 50 >> >> Oops, my mistake, that's not the solution. Give me another minute and I >> will post a better one one. > > The below does a better job: > (command should be all on one line) > > $ echo -e '100:CD001\nXXX\n200:CD001' | awk 'BEGIN { FS=":" ; done=0 } > /CD001/ && done==0 { print $1 - 50 ; done=1 }' > 50
You can do it without flags: $ echo -e '100:CD001\nXXX\n200:CD001' | awk -F: '/CD001/ { print $1 - 50 ; exit }' 50