Files
hpr_website/www/eps/hpr2659/hpr2659_bash11_ex5.sh

16 lines
385 B
Bash
Executable File

#!/bin/bash
#
# String comparison with a pattern in a variable. The pattern matches any
# word that ends with 'man' that is longer than 3 letters.
#
pattern="+([[:word:]])man"
echo "Pattern is: $pattern"
for str in 'man' 'woman' 'German' 'Xman' 'romance' ''; do
if [[ $str == $pattern ]]; then
echo "Matched '$str'"
else
echo "Didn't match '$str'"
fi
done