2
0

xd.lua 364 B

1234567891011121314
  1. -- hex dump
  2. -- usage: lua xd.lua < file
  3. local offset=0
  4. while true do
  5. local s=io.read(16)
  6. if s==nil then return end
  7. io.write(string.format("%08X ",offset))
  8. string.gsub(s,"(.)",
  9. function (c) io.write(string.format("%02X ",string.byte(c))) end)
  10. io.write(string.rep(" ",3*(16-string.len(s))))
  11. io.write(" ",string.gsub(s,"%c","."),"\n")
  12. offset=offset+16
  13. end