Check for a string in a folder with an if statement

view story

http://stackoverflow.com – I m looking to do an action when a bahsscript find a string in files on my home but somehow it's does not work and I don't understand why.. I have the impression that my grep does not return 0 (whereas the string is really present in a file). #!/bin/bash find /home/ -type f | xargs grep -q 'stringtofind' if [ $? == 0 ] #if the result is not equal to zero then echo "Action" else echo "Pas d'action" exit 1 fi exit 0 When I'm doing the following my shell returns me 123 instead of 0 find /home/anselmewebsite/ -type f | xargs grep -q 'stringtofind' ; echo $? shell returns : (HowTos)