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 349 views
1 answer 333 views
1 answer 315 views
1 answer 364 views
1 answer 325 views
3 answers 471 views
2 answers 733 views
...