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 354 views
1 answer 339 views
1 answer 317 views
1 answer 366 views
1 answer 330 views
3 answers 479 views
2 answers 736 views
...