Is there a way to search for a hex value in files / folders? I've tried the following:

grep -P "[\x01\x02\x03]"

but that doesn't work (there is no error, but it doesn't search for these hex values).


To search through file and folders add r(recursive) option:

grep -Pr "[\x01\x02\x03]"
  • Thank you for your answer. Yes, now It scans through very many files, and it outputs very many files. Is it possible, that it doesn't look only for 0x01 0x02 0x03 in that order, but also for 0x02 0x01 0x03 and 0x02 0x03 0x01, and so on? I am looking for a 6 byte hex value, and I know that this only exists 5 times on my SD card ( I've checked this with a hex editor and searched the whole card for this hex value ). – Manuel Sep 11 '17 at 17:34
  • 1
    @Manuel, of course, if you want to find a strict sequence specify it without character class grep -Pr "\x01\x02\x03" – RomanPerekhrest Sep 11 '17 at 17:37
  • Thank you, that seems to work a little better now. But I've put a file on my SD Card where I've checked with my hex editor, that there is the hex value I am looking for, but if I use grep -Pr "\x01\x02\x03" it doesn't find anything, even if I add the file, where I know that it is inside. Is there another possibility to the files with these hex values? – Manuel Sep 11 '17 at 19:50
  • @Manuel, RomanPerekhrest's answer matches your question as it is presently formulated. Please rephrase your question and add all those missing details if this answer is not what you expect. – xhienne Sep 11 '17 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.