How to check if a file contains a specific string using Bash

I want to check if a file contains a specific string or not in bash. I used this script, but it doesn’t work:

 if [[ 'grep 'SomeString' $File' ]];then
   # Some Actions
 fi

What’s wrong in my code?

11 Answers
11

Leave a Comment