Sample Header Ad - 728x90

How do I trim bytes from the beginning and end of a file?

22 votes
3 answers
26817 views
I have a file, that has trash (binary header and footer) at the beginning and end of the file. I would like to know how to nuke these bytes. For an example, let's assume 25 bytes from the beginning. And, 2 bytes from the end. I know I can use truncate and dd, but truncate doesn't work with a stream and it seems kind of cludgey to run two commands on the hard file. It would be nicer if truncate, knowing how big the file was, could cat the file to dd. Or, if there was a nicer way to do this?
Asked by Evan Carroll (34663 rep)
May 24, 2017, 08:38 PM
Last activity: May 24, 2017, 09:57 PM