Checking if a string contains a substring in Bash


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. string='My string';
  2.  
  3. if [[ $string == *My* ]]
  4. then
  5. echo "It's there!";
  6. fi

URL: http://stackoverflow.com/questions/229551/string-contains-in-bash

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.