How to find if a substring exists in a string or not in Shell/Unix scripting

Shell @

This will be a common use case when we need to check some substring in a log or some file.  You can achieved by using the below scripts. In the below we need to search the keyword “freshers” in the string given

if [[ $string == *"freshers"* ]]; then
  echo "Substring found"
  echo "NOT FOUND"
Author: user

Leave a Reply