Hi there, In the following test, how to use shell var for pattern, regular expression. I need to accept pattern at argument, use it to pattern matching at shell script.
Test:
#!/bin/ksh
# name t.sh
exp="a@(a|b)"
touch aa ab ac
echo "\nTest without variable"
echo "---------------------"
ls -1 a@(a|b)
echo "\nTest with with variable(exp=$exp)"
echo "----------------------"
ls -1 $exp
######################################
# test
######################################
# chmod 775 t.sh
# t.sh
######################################
# test output
######################################
# Test without variable
# ---------------------
# aa
# ab
#
# Test with with variable(exp=a@(a|b))
# ----------------------
# a@(a|b) not found # <-- probelm
######################################