In a shell script, how can I find out if a string is contained within another string. In bash, I would just use =~, but I am not sure how I can do the same in /bin/sh. Is i
You can define a function
matches() { input="$1" pattern="$2" echo "$input" | grep -q "$pattern" }
to get regular expression matching. Note: usage is
if matches input pattern; then
(without the [ ]).
[ ]