How do I extract a single chunk of bytes from within a file?

后端 未结 5 1237
面向向阳花
面向向阳花 2020-12-07 16:01

On a Linux desktop (RHEL4) I want to extract a range of bytes (typically less than 1000) from within a large file (>1 Gig). I know the offset into the file and the size of t

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 16:46

    head -c + tail -c

    Not sure how it compare to dd in efficiency, but it is fun:

    printf "123456789" | tail -c+2 | head -c3
    

    picks 3 bytes, starting at the 2nd one:

    234
    

    See also: https://stackoverflow.com/a/1272995/895245

提交回复
热议问题