I want to have a bash script which:
- Runs the "strings" command on each file in current directory
- Searches the output of strings for each file for specific terms using grep
I have the following, but the script output does not show any matches:
#!/bin/bash
echo "Searching files in directory for secrets and urls"
for file in ./*
do
echo "=====$file====="
strings ${file} | egrep -wi --color 'secret\|password\|key\|credential|\http'
done
I've also tried strings $file | egrep -wi --color 'secret\|password\|key\|credential|\http'
and eval "strings ${file} | egrep -wi --color 'secret\|password\|key\|credential|\http'"
but these do not appear to work. The script outputs the filenames, but not the matches.
\\
since you're using ERE. – Jetchisel May 02 '20 at 07:01