Command to convert hexdump back to text

Majid Fouladpour picture Majid Fouladpour · Oct 28, 2017 · Viewed 10.2k times · Source

I am using Catfish to find files containing certain text. Some of the files found instead of plain text contain something which looks like a hex dump:

3c3f 7068 700a 0a66 756e 6374 696f 6e20
7573 6572 5f65 7869 7374 7328 2475 6e29
207b 0a09 7265 7475 726e 2074 7275 653b
0a7d 0a0a 0a3f 3e00 0000 0000 0000 0000

I.e. always 8 columns and each row containing 16 bytes. Line one above should be

<?php
function

Is there a command to unhex the file and print the content?

Answer

etopylight picture etopylight · Oct 28, 2017

Use xxd with the revert option -r

xxd -p -r file.txt

gives a result of

<?php

function user_exists($un) {
        return true;
}


?>