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 m

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` does

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 one

Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game)

2022-12-20 Thread Thomas Schmitt
Hi, The Wanderer wrote: > With the '-o' option, grep prints only the parts of the line that were > matched - but the plural here is very relevant. If that guess is > correct, then the "line" in question has *four* occurrences, so grep > prints them all - each on a separate line of output. The man

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 going

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:10, The Wanderer wrote: > On 2022-12-20 at 02:51, Thomas Schmitt wrote: > >>> offst=$( expr \ > >>> $( grep -a -o -b -m 1 CD001 cdimage.iso \ > >>> | sed -e 's/:/ /' \ > >>> | awk '{ print $1 }' ) - 32769 ) > > > > The Wande

'grep -o -m' (was Re: Can't mount CD image of Win95 game)

2022-12-20 Thread The Wanderer
On 2022-12-20 at 02:51, Thomas Schmitt wrote: > Hi, > > i wrote: >>> To obtain the offset of the first occurence of "CD001", do >>> >>> offst=$( expr \ >>> $( grep -a -o -b -m 1 CD001 cdimage.iso \ >>> | sed -e 's/:/ /' \ >>> | awk '{ print $1 }' )