How to check if a file contains a specific string using Bash
if grep -q SomeString “$File”; then Some Actions # SomeString was found fi You don’t need [[ ]] here. Just run the command directly. Add -q option when you don’t need the string displayed when it was found. The grep command returns 0 or 1 in the exit code depending on the result of search. … Read more