Posts

Showing posts with the label pipe

Shell command to list file names where the matching is found

Shell command to list file names where the matching is found I am trying to search through a list of binary files to find some keywords on Mac. The following works to list out all the matches, but it doesn't show me the list of files where it is being found: find . -type f -exec strings {} ;|grep "Bv9qtsZRgspQliITY4" Is there any trick to do this? Do you still want to print the matches, or just the files’ names/paths? – Biffen Jun 29 at 10:07 5 Answers 5 Using -exec with a wee ‘script’: -exec find . -type f -exec sh -c 'strings "$1" | grep -q "Bv9qtsZRgspQliITY4"' -- {} ; -print The above will print the paths of all the matching files. If you also want to print the matches you can use: find . -typ...