How to check if a string contains a substring in Bash

1 Answer

0 votes
str="bash java c c++"
 
if [[ $str = *java* ]]; then
    echo "found"
else
    echo "not found"
fi
 
 
 
# run:
#
# found
#

 



answered May 26, 2021 by avibootz
edited May 26, 2021 by avibootz

Related questions

1 answer 227 views
1 answer 209 views
1 answer 212 views
1 answer 252 views
1 answer 221 views
3 answers 289 views
2 answers 568 views
...