While writing scripts, sometimes you just need to know if a file contains the pattern and act based on the exit status of the command. Instead of redirecting the output to /dev/null you can use the -q option. This will avoid printing anything on stdout and also provides speed benefit as processing would be stopped as soon as the given condition is satisfied.