Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #string #starts
ADD COMMENT
Topic
Name
6+9 =