Hexdump: Hexdump a binary file and convert it back

Hi,

for hexdump (binary) files and converting back the Linux command line xxd works perfect.


Some examples. A hexdump of a xml file umts.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<umts>
<settings>
<PIN/>
<AllowRoaming>0</AllowRoaming>
<HomeNetwork/>
<SIM/>
</settings>
</umts>

Convert the XML file to hexdump format

michael@debdev ~ # xxd umts.xml
00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231  <?xml version="1
00000010: 2e30 2220 656e 636f 6469 6e67 3d22 6973 .0" encoding="is 
00000020: 6f2d 3838 3539 2d31 223f 3e0a 3c75 6d74 o-8859-1"?>.<umt 
00000030: 733e 0a3c 7365 7474 696e 6773 3e0a 3c50 s>.<settings>.<P
....
michael@debdev ~ # xxd umts.xml > umts.hex

Or convert it to an “simple” hex format

michael@debdev ~ # xxd -p umts.xml
3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d22
69736f2d383835392d31223f3e0a3c756d74733e0a3c73657474696e6773
3e0a3c50494e2f3e0a3c416c6c6f77526f616d696e673e303c2f416c6c6f
....
michael@debdev ~ # xxd umts.xml > umts_simple.hex

And reverse the “simple” hex format

michael@debdev ~ # cat umts_simple.hex
3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d22
69736f2d383835392d31223f3e0a3c756d74733e0a3c73657474696e6773
3e0a3c50494e2f3e0a3c416c6c6f77526f616d696e673e303c2f416c6c6f
....
michael@debdev ~ # xxd -r -p umts_simple.hex
<?xml version="1.0" encoding="iso-8859-1"?>
<umts>
<settings>
<PIN/>
<AllowRoaming>0</AllowRoaming>
<HomeNetwork/>
.....

And from hexdump format

michael@debdev ~ # cat umts.hex
00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231 <?xml version="1
00000010: 2e30 2220 656e 636f 6469 6e67 3d22 6973 .0" encoding="is
00000020: 6f2d 3838 3539 2d31 223f 3e0a 3c75 6d74 o-8859-1"?>.<umt
00000030: 733e 0a3c 7365 7474 696e 6773 3e0a 3c50 s>.<-------
michael@debdev ~ # xxd -r umts.hex
<?xml version="1.0" encoding="iso-8859-1"?>
<umts>
<settings>
<PIN/>
<AllowRoaming>0</AllowRoaming>
<HomeNetwork/>
....

Michael

Advertisment to support michlstechblog.info

Time limit is exhausted. Please reload CAPTCHA.

Original Theme by Schiy · Powered by WordPress