bash - regular expression approach
I just found this in the net while reading and browsing about bash, and I wanted to take this notes for my own sake :D.
#! /bin/bash
VARIABLE="Let's test this string!"
# This is for regular expressions:
if [[ "$VARIABLE" =~ "Let's.*ring" ]]
then
echo "matched"
else
echo "nope"
fi
# And here we have Bash Patterns:
if [[ "$VARIABLE" == L*ing! ]]
then
echo "matched"
else
echo "nope"
fi
Comments