Re: use of awk instead of complex multielement commands (was Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game))

2022-12-20 Thread David
On Wed, 21 Dec 2022 at 04:18, Lee wrote: > On 12/20/22, David wrote: > > $ 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/

Re: use of awk instead of complex multielement commands (was Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game))

2022-12-20 Thread Lee
On 12/20/22, David wrote: > On Tue, 20 Dec 2022 at 22:04, David wrote: >> On Tue, 20 Dec 2022 at 22:02, David 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

Re: use of awk instead of complex multielement commands (was Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game))

2022-12-20 Thread Stefan Monnier
> Not that that is always important. But I just commented today > because so often 'awk' is ignored as if its only capability is 'print $1' > when in fact it is actually very powerful but neglected. FWIW, `sed` can also do that job. Tho the subtraction part would take a lot more work (`sed`

Re: use of awk instead of complex multielement commands (was Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game))

2022-12-20 Thread David
On Tue, 20 Dec 2022 at 22:04, David wrote: > On Tue, 20 Dec 2022 at 22:02, David 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

Re: use of awk instead of complex multielement commands (was Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game))

2022-12-20 Thread David
On Tue, 20 Dec 2022 at 22:02, David 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.

Re: use of awk instead of complex multielement commands (was Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game))

2022-12-20 Thread David
On Tue, 20 Dec 2022 at 21:53, The Wanderer wrote: > On 2022-12-20 at 05:37, David wrote: > > On Tue, 20 Dec 2022 at 21:10, The Wanderer wrote: > >> On 2022-12-20 at 02:51, Thomas Schmitt wrote: > >>> This contradicts the promises of man grep about option -m. > >> It does seem to, at least at a

use of awk instead of complex multielement commands (was Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game))

2022-12-20 Thread The Wanderer
On 2022-12-20 at 05:37, David wrote: > On Tue, 20 Dec 2022 at 21:10, The Wanderer > wrote: > >> On 2022-12-20 at 02:51, Thomas Schmitt wrote: >>> This contradicts the promises of man grep about option -m. >> >> It does seem to, at least at a glance - but I think I've figured >> out what's