I'm trying to find multiple patterns (I have a file of them) in multiple differents files with a lot of subdirs. I'm trying to use exit codes for not outputting all patterns found (because I need only the ones which are NOT found), but exit codes doesn't work as I understand them.
while read pattern; do grep -q -n -r $pattern ./dir/ if [ $? -eq 0 ]; then : #echo $pattern ' exists' else echo $pattern " doesn't exist" fi done <strings.tmp
strings.tmp. Are you trying to match regular expression patterns or fixed strings? How exactly is the code not working? Please edit your question to provide these details.