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: Can't mount CD image of Win95 game

2022-12-20 Thread Thomas Schmitt
Hi, i meanwhile had a chance to inspect the image file and found that it shows a repeating pattern of bytes with value 255 every 2352 bytes. This corresponds to the size of medium level CD sectors, as can be obtained by SCSI command "READ CD" (e.g. via Linux ioctl CDROMREADRAW). CD-DA audio secto

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: Can't mount CD image of Win95 game

2022-12-20 Thread Thomas Schmitt
Hi, Yvan Masson wrote: > Kernel logs say "isofs_fill_super: get root inode failed". So there is more stuff inserted between the volume descriptor and the root directory of the ISO. (The descriptor contains a minimal directory record which points to the content of the root directory. All attribut

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 }' )

Re: Can't mount CD image of Win95 game

2022-12-20 Thread Yvan Masson
So the new safer proposal is: offst=$( expr \ $( grep -a -o -b -m 1 CD001 cdimage.iso \ | head -1 \ | sed -e 's/:/ /' \ | awk '{ print $1 }' ) - 32769 ) Afterwards $offst should hold a number > 0, which may be used with mo

Re: Can't mount CD image of Win95 game

2022-12-19 Thread Thomas Schmitt
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 }' ) - 32769 ) The Wanderer wrote: > Cutting down the comm

Re: Can't mount CD image of Win95 game

2022-12-19 Thread The Wanderer
On 2022-12-19 at 16:07, Thomas Schmitt wrote: > Hi, > > Yvan Masson wrote: >> I am really not at ease using tools like hexdump, > > I pondered a bit more. If it's an ISO filesystem wrapped into some header > and maybe a footer, then mount option -o offset= could help. > > To obtain the offset o

Re: Can't mount CD image of Win95 game

2022-12-19 Thread Thomas Schmitt
Hi, Yvan Masson wrote: > I am really not at ease using tools like hexdump, I pondered a bit more. If it's an ISO filesystem wrapped into some header and maybe a footer, then mount option -o offset= could help. To obtain the offset of the first occurence of "CD001", do offst=$( expr \

Re: Can't mount CD image of Win95 game

2022-12-19 Thread Yvan Masson
Le 19/12/2022 à 16:34, Thomas Schmitt a écrit : Hi, i wrote: dd if=cdimage.iso bs=1 count=64 | od -t c Yvan Masson wrote: 000 \0 377 377 377 377 377 377 377 377 377 377 \0 \0 002 \0 001 020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 This does not give m

Re: Can't mount CD image of Win95 game

2022-12-19 Thread Thomas Schmitt
Hi, i wrote: > >dd if=cdimage.iso bs=1 count=64 | od -t c Yvan Masson wrote: > 000 \0 377 377 377 377 377 377 377 377 377 377 \0 \0 002 \0 001 > 020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 This does not give me ideas. > >strings cdimage.iso | head -1

Re: Can't mount CD image of Win95 game

2022-12-19 Thread Yvan Masson
Hi Thomas, Le 19/12/2022 à 13:28, Thomas Schmitt a écrit : Hi, Yvan Masson wrote: I have a CD image of an old Win 95 game. [...] $ file cdimage.iso cdimage.iso: data So the cdimage.iso is not an ISO 9660 filesystem or somehow defaced. (Does the image file perhaps begin by "RIFFCDXA" ?)

Re: Can't mount CD image of Win95 game

2022-12-19 Thread Thomas Schmitt
Hi, Yvan Masson wrote: > I have a CD image of an old Win 95 game. [...] > $ file cdimage.iso > cdimage.iso: data So the cdimage.iso is not an ISO 9660 filesystem or somehow defaced. (Does the image file perhaps begin by "RIFFCDXA" ?) What do you get from the following runs ? dd if=cdimage