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