Quantcast
Channel: Linux command to retrieve a byte range from a file - Server Fault
Viewing all articles
Browse latest Browse all 7

Answer by jeffpkamp for Linux command to retrieve a byte range from a file

$
0
0

I know this is old, and asked for a "linux" command in the title, but python is perfect for this and comes with most linux distributions. It's as easy as this:

python -c 'f=open("myfile.txt","rb");f.seek(100);print(f.read(100));f.close()' | SomeOtherProgram

f.seek(n,0) goes n bytes from the start of the program, and f.read(n) reads the number of bytes you want.

I've not found any other options that make it that easy.


Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>