Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash check if string starts with substring

# Original source: Advanced Bash Scripting Guide (http://tldp.org/LDP/abs/html/comparison-ops.html)
# The == comparison operator behaves differently within a double-brackets
# test than within single brackets.

[[ $a == z* ]]   # True if $a starts with a "z" (wildcard matching).
[[ $a == "z*" ]] # True if $a is equal to z* (literal matching).
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #check #string #starts #substring
ADD COMMENT
Topic
Name
7+6 =