batty batty - 11 months ago 43
Bash Question

Find substring in shell script variable

I have a string


in my shell script code. I need a conditional statement to check if
is present in that string.

What command should I use to get either true or false boolean as output?
Or is there any other way of checking it?


What shell? Using bash:

if [[ "$VAR" =~ "UAT" ]]; then
    echo "matched"
    echo "didn't match"