Last active
September 24, 2019 08:16
-
-
Save takeshy/128f9f7f7214ef7b5926a2f5d2b91273 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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