cat can't do that.
cat can't do that.
> dd if=/tmp/file1 bs=1 skip=50000000 count=10000000
or you can use any block size you want and treat skip and count as byte counts, not block counts.
> dd if=/tmp/file1 bs=4M skip=50M count=10M iflag=skip_bytes,count_bytes
Option 1 will run at Kilobytes per second as it is transferring 1 byte at a time (my test gives me 933kB/s)
Option 2 will run a 100's MB per second as it is transferring 4MB at a time (my test gives me 202MB/s).
Edit: What I should have said at the top of the post was "If you want to extract data from a file whose size is not an integer block multiple". In the above example you could have used a Blocksize of 10MB for the same result. You cannot do this for an oddly size extraction (say 1234567bytes).
Why doesn't the man page say anything about these flags? They are completely obscure becasue of that.
One other nuggets of wisdom which is very poorly documented in the man page: if you have a long running dd process (I often have 12+ hr dd processes reading 10+TB tapes) you can send a USR1 signal to check the progress. Very useful to check if your tape drive has had a hardware failure.
Information on both this and the byte counts are in my man page (GNU coreutils 8.30 on Linux Mint 20) around lines 130.
Debian testing, coreutils 9.1.
It is also in Coreutils 8.22 in RHEL7.
https://man7.org/linux/man-pages/man1/dd.1.html
Edit: I just found this in the coreutils 9.0 changelog:
dd now counts bytes instead of blocks if a block count ends in "B".
For example, 'dd count=100KiB' now copies 100 KiB of data, not
102,400 blocks of data. The flags count_bytes, skip_bytes and
seek_bytes are therefore obsolescent and are no longer documented,
though they still work.So you can simply do something like:
dd if=foo skip=nB count=mB bs=4M of=bar
To get m bytes from offset n