I am getting syntax error while using the if condi

2019-10-21 06:13发布

问题:

This question already has an answer here:

  • Syntax error checking whether account number is numeric 2 answers
if [[ ${account_nr} =~ ^[0-9]+$ && ${from_account_nr} =~ ^[0-9]+$ ]]

In the above I am getting the values for account_nr, from_account_nr from a file. I need to check account_nr and from_account_nr both are numeric or not. but here I am getting Syntax error.

Please help me

回答1:

All fine here:

if [[ ${account_nr} =~ ^[0-9]+$ && ${from_account_nr} =~ ^[0-9]+$ ]]; then echo a ; else echo b ; fi
b


标签: shell