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 243 views
1 answer 228 views
1 answer 231 views
1 answer 266 views
1 answer 233 views
3 answers 310 views
2 answers 587 views
...