Skip to content

Instantly share code, notes, and snippets.

@detunized
Created September 13, 2017 10:27
Show Gist options
  • Save detunized/f7edcc0b4fa3a17feebb95ef915d8c4a to your computer and use it in GitHub Desktop.
Save detunized/f7edcc0b4fa3a17feebb95ef915d8c4a to your computer and use it in GitHub Desktop.
Split binary file on hex pattern
File.binread("filename.bin").split(/(?=\x15\x01)/).each_with_index do |data, i|
File.open("filename-%02d.bin" % i, "wb") do |io|
io.write data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment