title: How do you tell if a string contains another string in POSIX sh?
body: <p>I want to write a Unix shell script that will do various logic if there is a string inside of another string. For example, if I am in a certain folder, branch off. Could someone please tell me how to accomplish this? If possible I would like to make this not shell specific (i.e. not bash only) but if there's no other way I can make do with that.</p>
  
  <pre><code>#!/usr/bin/env sh
  
  if [ "$PWD" contains "String1" ]
  then
      echo "String1 present"
  elif [ "$PWD" contains "String2" ]
  then
      echo "String2 present"
  else
      echo "Else"
  fi
  </code></pre>