Answers for "bash string starts with"

1

bash string starts with

[[ $a == z* ]]   # True if $a starts with a "z" (wildcard matching).
[[ $a == "z*" ]] # True if $a is equal to z* (literal matching).

if [[ "$HOST" =~ ^user.* ]]; then
    echo "yes"
fi

if [[ "$HOST" =~ ^user.*|^host1 ]]; then
    echo "yes"
fi
Posted by: Guest on April-07-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language