You need to use double brackets to enable advanced functions that are more like traditional programming languages. For example, instead of -a use || instead of -o and && . Double brackets are also required to complete the pattern (matching .
In addition, brackets should be used for the entire expression, and not for each subexpression separately, and should include || .
I would use a line like:
if [[ $1 == [+-][0-9][0-9][0-9][0-9] && $2 == [+-][0-9][0-9][0-9][0-9][0-9] ]] then echo "success" else echo "fail" fi
EDIT : using == instead of != (Why is it so negative?) And remove references to the regular expression (uses pattern matching).
source share