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 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 )
>
> (It's the binary 1 before "CD001" which is normally at 32768. So grep will
> report byte position 32769 for "CD001" if offset is 0.)
This apparently isn't universally reliable. When I tested it with a
random ISO I happen to have lying around (a bullseye netinst from
2021-04-15), I got an error from expr about unexpected arguments.
Cutting down the command line led me to discover that even with '-m 1',
four different numbers are printed by the grep-pipeline subshell.
(Without '-m 1', seven are printed.)
I'm not entirely sure why this may happen, but it's what I've observed.
Inserting '| head -n 1 ' into the pipeline, right after grep, got this
to produce the expected first-occurrence-only information.
--
The Wanderer
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw
Attachment:
signature.asc
Description: OpenPGP digital signature