Reputation: 378
String :
[email protected]
Want to check for :
@
.com
if those two are found, I want to set my boolean true
bool_one=true
How do I do this? I tried
if [ $word|grep[@] = $word]
but it's not working.
Upvotes: 0
Views: 32
Reputation: 63902
you can also
s='[email protected]'
[[ "$s" =~ (.*)@(.*)\.com ]] && echo "name: ${BASH_REMATCH[1]} domain ${BASH_REMATCH[2]}.com"
Upvotes: 0
Reputation: 785068
You can do it like this:
s='[email protected]'
[[ "$s" == *@*.com ]] && echo "true"
Upvotes: 2