Note that there are some explanatory texts on larger screens.

plurals
  1. POSyntax error checking whether account number is numeric
    primarykey
    data
    text
    <pre><code>if [[ ${account_nr} =~ ^[0-9]+$ &amp;&amp; ${from_account_nr} =~ ^[0-9]+$ ]] </code></pre> <p>This is intended to check whether the account number is numeric or not. I'm getting a syntax error.</p> <p><em>An earlier version of this question lacked the space between <code>if</code> and <code>[[</code>; the actual code has the required space.</em></p> <p>It showing the below error message:</p> <pre><code>syntax error: `${account_nr}' missing expression operator </code></pre> <p>I am using bash shell. You people are telling it is working. but I am trying with example like below it is giving error.</p> <pre><code>jai = "CNM" hanuman = "BRK" if [[ $jai =~ ^[0-9]+$ &amp;&amp; $hanuman =~ ^[0-9]+$ ]] then echo "Jai hanuman" echo "valid input" fi </code></pre> <p>it showing the error like below.</p> <pre><code>./temp.sh: line 11: jai: command not found ./temp.sh: line 12: hanuman: command not found </code></pre> <p>In my actual program it is not working: " Now I am givig the problem indetail:"</p> <ol> <li>In one file I stored all the transactions details, each line for one transaction.</li> <li>by using the below while loop each time I am reading one transaction detail while read blank srvrtid blank member_nr blank account_nr blank acct_type blank routing_nr blank amount blank proc_date blank from_account_nr blank from_acct_type blank do</li> <li><p>Inside this I want to check account_nr and from_account_nr values are numeric or not the if condition I have given the below</p> <p><code>if [[ ${SQL_STATEMENT} -gt 0 &amp;&amp; ${account_nr} =~ ^[0-9]+$ &amp;&amp; ${from_account_nr} =~ ^[0-9]+$ ]]</code></p></li> <li><p>It is not showing any error for <code>&amp;{SQL_STATEMENT}</code>, this <code>SQL_STATEMENT</code> is assigned with the value returned by the SELECT query.(total number of transactions).</p></li> <li><p>when I run the script it is showing the below error.</p> <p>syntax error: `${account_nr}' missing expression operator.</p></li> </ol> <p>please help for my problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload