Skip to content

Instantly share code, notes, and snippets.

@takeshy
Last active September 24, 2019 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takeshy/128f9f7f7214ef7b5926a2f5d2b91273 to your computer and use it in GitHub Desktop.
Save takeshy/128f9f7f7214ef7b5926a2f5d2b91273 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
if ARGV.length != 1
puts "#{$0} outputfile"
exit -1
end
unless file = File.open(ARGV[0],"wb")
puts "#{$0} outputfile"
puts "#{ARGV[0]} can't write"
exit -1
end
begin
datas = []
STDIN.each do |line|
datas.concat(line.scan(/[\da-zA-Z]{2}/).map do|i| i.hex end)
end
file.write(datas.pack("C*"))
ensure
file.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment