Strings In Depth5 / 17
Up next

Contains a substring

#!/usr/bin/env bash
s="the quick brown fox"
# inside [[ ]], == does glob matching; wildcards mean contains
if [[ $s == *quick* ]]; then
  echo "found it"
fi
# case can match several patterns cleanly
case $s in
  *fox*) echo "has fox" ;;
  *)     echo "no fox" ;;
esac
What you're solving

[[ $s == *sub* ]] tests membership