s1m0ne
asked on
Equivalent Of Regex Matching Operator Before Bash Version 3
Hello,
The following is an example from http://www.tldp.org/LDP/abs/html/bashver3.html for bash version 3:
----------
#!/bin/bash
variable="This is a fine mess."
echo "$variable"
if [[ "$variable" =~ "T*fin*es*" ]]
# Regex matching with =~ operator within [[ double brackets ]].
then
echo "match found"
# match found
fi
----------
How can one do the same thing in earlier versions of bash (2 for instance)?
Thanks in advance,
s1m0ne
The following is an example from http://www.tldp.org/LDP/abs/html/bashver3.html for bash version 3:
----------
#!/bin/bash
variable="This is a fine mess."
echo "$variable"
if [[ "$variable" =~ "T*fin*es*" ]]
# Regex matching with =~ operator within [[ double brackets ]].
then
echo "match found"
# match found
fi
----------
How can one do the same thing in earlier versions of bash (2 for instance)?
Thanks in advance,
s1m0ne
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
amit_g,
That's the stuff. Thanks a lot!
s1m0ne
That's the stuff. Thanks a lot!
s1m0ne
...
echo $variable | grep -e "T*fin*es*" >/dev/null
if [ $? -eq 0 ]; then
echo "match found"
fi