Text based Hex String to Binary File Program Help Request

preview_player
Показать описание

An Upwork programmer Ivan Kovalenko
Рекомендации по теме
Комментарии
Автор

Wondering if AWK on Linux is the easiest way?

ForgottenMachines
Автор

An Upwork programmer Ivan Kovalenko

#!/usr/bin/ruby

if $*[ 0 ].nil?() or not FileTest.exists?( $*[ 0 ] ) then
puts( "Usage: #{ $0 } <input-file>" )
exit( 1 )
end

i = 1
File.open( $*[ 0 ], 'r' ) { | input |
while not input.eof?() do
line = input.readline().chomp()
next if line.empty?()
File.open( "#{ $*[ 0 ].gsub( /\..+$/, '' ) }-#{ sprintf( '%06d', i ) }.bin", 'wb' ) { | output |
output.write( [ line ].pack( 'H*' ) )
}
i += 1
end
}

ForgottenMachines