Is there a way to specify reading in file bytes that are at a position/offset within a binary file from the cmdline? (i.e. one-liners) e.g.
perl -ne <...seek n bytes into file... do stuff...> inputfile
I haven't seen this and have tried using seek, sysseek, etc.
just want to experiment with pack
and unpack
by reading in a length of bytes at different offsets within a file.
UPDATE
In addition to the accepted answer, I just want to add the following equivalent answer but (to me) easier to remember+read
perl -lne 'BEGIN{$/=undef, $offset=1, $len=2} print unpack("H*", substr($_, $offset, $len))' input
UPDATE2 For the purpose of doing hexdumps the following works
perl -0777 -ne '(printf "0x%02x ", $_) for (unpack "C*", substr($_, 0x1, 0x2))' input