Skip to content

Instantly share code, notes, and snippets.

@ferryzhou
Created February 7, 2013 20:46
Show Gist options
  • Save ferryzhou/4734020 to your computer and use it in GitHub Desktop.
Save ferryzhou/4734020 to your computer and use it in GitHub Desktop.
concatenate binary files with ruby
# given a directory or a set of files
# concatenate the binary files
# output a single binary file
# usage:
# ruby concatenate_binary_files "/xxx/xx/*.bin" "/xxx/xx.bin"
infiles = ARGV[0]
outpath = ARGV[1]
File.open(outpath, 'wb') do |outfile|
Dir.glob(infiles).each do |file|
p file
outfile.write(File.open(file, 'rb').read)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment