Hexdump reverse command

前端 未结 4 647
悲哀的现实
悲哀的现实 2021-02-08 14:54

The hexdump command converts any file to hex values.

But what if I have hex values and I want to reverse the process, is this possible?

4条回答
  •  情话喂你
    2021-02-08 15:30

    There is a tonne of more elegant ways to get this done, but I've quickly hacked something together that Works for Me (tm) when regenerating a binary file from a hex dump generated by hexdump -C some_file.bin:

    sed 's/\(.\{8\}\)  \(..\) \(..\) \(..\) \(..\) \(..\) \(..\) \(..\) \(..\)/\1: \2\3 \4\5 \6\7 \8\9/g' some_file.hexdump | sed 's/\(.*\)  \(..\) \(..\) \(..\) \(..\) \(..\) \(..\) \(..\) \(..\)  |/\1 \2\3 \4\5 \6\7 \8\9  /g' | sed 's/.$//g' | xxd -r > some_file.restored
    

    Basically, uses 2 sed processeses, each handling it's part of each line. Ugly, but someone might find it useful.

提交回复
热议问题