title: Round up integer in shell script
body: <p>I'm ALL NEW in shell script , hence have a question about how to round up integer.</p>
  
  <p>Here is a line of the code from a script by keke(smstools3 developer)</p>
  
  <pre><code>  balance=$(substr "$result" "$balance_prefix" "$balance_suffix")
  </code></pre>
  
  <p>And my balance is <code>111.12</code> , and I wish to round it up.</p>
  
  <p>I tried</p>
  
  <pre><code>    balance1=$(substr "$result" "$balance_prefix" "$balance_suffix")
      balance=$("%0.f\n" "$balance1")
  </code></pre>
  
  <p>or</p>
  
  <pre><code>    balance1=$(substr "$result" "$balance_prefix" "$balance_suffix")
      balance=$(ceil($balance1))
  </code></pre>
  
  <p>Both refer from some answers after google it , I not even know if the syntax is correct.And of course both example return blank.</p>
  
  <p>Any hints or advice?Thank you.</p>
  
  <p>Edit:</p>
  
  <pre><code># Check that required words exists:
  if [[ "$result" == *${balance_prefix}* ]] &amp;&amp; \
     [[ "$result" == *${balance_suffix}* ]]
  then
    # Get the balance and check it:
    balance=$(substr "$result" "$balance_prefix" "$balance_suffix")
    balance_low=0
  
    if [ $(expr "$balance" + 1 2&gt; /dev/null) ]; then
      [ $balance -le $alert_balance ] &amp;&amp; balance_low=1
    else
      echo "Error while parsing an integer: $balance"
    fi
  else
    echo "Error while parsing the answer (balance): $result"
  fi
  </code></pre>
  
  <p>source : <a href="http://smstools3.kekekasvi.com/topic.php?id=320" rel="nofollow">http://smstools3.kekekasvi.com/topic.php?id=320</a></p>