Situation:
You have a (binary) file, and you need to remove the first n bytes of data in it.
Solution:
Use dd. Read more about it, here.
Here is how to do it:
$ dd if=input_file ibs=1 skip=N of=output_file
N is the number of bytes to be removed.
example:
$ dd if=input_file.dat ibs=1 skip=3 obs=10M of=output_file.dat
Now, what if you need to remove the first N bytes and the last M bytes from a file?
$ dd if=input_file.dat ibs=1 skip=N count=X of=output_file.dat
To calculate X:
X = acutal_file_size_in_bytes - N - M
I recommend you to read through the man pages, and play around with ibs, obs, bs, count values and other parameters that might be useful.
Cool beans! Thanks. A minor improvement. You can remove N bytes faster by switching the block size and skip size.
ReplyDeletedd if=input_file ibs=N skip=1 of=output_file
Vinai
--
www.ece.purdue.edu/~vsundar
@vinai thanks for the improvement.
ReplyDeleteOH COME ON, CAN SOMEONE FROM THE FUCKING WORLD TELL HOW TO FUCKING DO THIS FROM WINDOWS WITH A FUCKING BAT FILE?!?!
ReplyDeleteInstall a copy of cygwin. And you can then have access to a large cross section of the standard unix tool set in Windows.
DeleteYeap, remove Windows and switch to Linux ;)
ReplyDeleteSometimes I need to fück my win7
ReplyDelete