Search code examples
filesedbigdatahead

Read a file from byte a until byte b


I want to break a big file into to smaller files mainly.

I use stream because I do not want to keep the big file in my disk.

What I am looking it is something similar to:

sed -n 'a,bp,' #this uses lines in file while i want bytes

or:

cat filename|head -c a| tail -c (a-b)  # this way takes too long with big files

Solution

  • If performance is an issue, and you are using large files, I think you would do better with a bigger block size in dd, like this

    dd bs=$a skip=1 if=filename | dd "bs=$((b-a))" count=1