Q:

how to check whether a string contains a special character or not in bash

if [[ $str =~ ['!@#$%^&*()_+'] ]]; then
    echo yes
else
    echo no
fi
0

New to Communities?

Join the community