dash 和 bash 的語法有差異,在 dash 下,用正則表達式匹配字符串的時候,提示“[[ not found”,需要使用egrep:
dash寫法:
if echo "$msg" | egrep -q "$regex_string"; then
xxx
bash寫法:
if [[ "$msg" =~ regex ]] ;then
xxx
dash 和 bash 的語法有差異,在 dash 下,用正則表達式匹配字符串的時候,提示“[[ not found”,需要使用egrep:
dash寫法:
if echo "$msg" | egrep -q "$regex_string"; then
xxx
if [[ "$msg" =~ regex ]] ;then
xxx