2014年4月28日 星期一

Bash Script 字串判斷

string='script test string';

if [[ $string == 'script test string' ]]
then
  echo "0 It's there!";
fi

if [[ $string == *test* ]]
then
  echo "1 It's there!";
fi

if [[ $string == *string ]]
then
  echo "2 It's there!";
fi

if [[ $string == script* ]]
then
  echo "3 It's there!";
fi

沒有留言: