Pádraig Brady wrote:
> On 16th June 2008, Paul Eggert wrote:
>> Pádraig Brady <[email protected]> writes:
>>
>>> 5. I think it would be nice for dd to support reading portions of
>>> a file efficiently. As far as I can see it can only do it by reading
>>> 1 byte at a time. Perhaps skip_bytes=x and count_bytes=x would
>>> be useful additions?
>> These also sound like good suggestions.
> 
> I just noticed in the info docs for dd that there
> is a method to achieve skip_bytes at least:
> 
> (dd bs=1 skip=123456 count=0 && dd bs=8192) < file

For my reference one could also efficiently
achieve count_bytes using the following:

bs=8192
skip_bytes=$1
count_bytes=$2
(
  dd bs=1 skip=$skip_bytes count=0
  dd bs=$bs count=$(($count_bytes / $bs))
  dd bs=$(($count_bytes % $bs)) count=1
) < file

Still, supporting those internal to dd would
be simpler, more portable and robust.

cheers,
Pádraig.


Reply via email to