title: How to use ipcalc to validate IP in a Bash script?
body: <p>I need to validate an IP with bash script and if it was valid, run another command. i used <strong>ipcalc</strong> command. but not sure why return wrong result ... I changed <strong>0</strong> to <strong>1</strong> .. <strong>false</strong> .. <strong>true</strong> but never got <strong>valid</strong> 
  . here is the code:</p>
  
  <pre><code>#!/bin/bash
  if [[ $(ipcalc -cs 8.8.8.8) = 0 ]]
   then
    echo "valid"
   else
    echo "invalid"
  fi
  </code></pre>
  
  <p>but this one working fine in bash script and direct command line:</p>
  
  <pre><code>[root@sv89]# ipcalc -cs 8.8.8.8 &amp;&amp; echo valid || echo invalid
  valid
  [root@sv89]# ipcalc -cs 8.8.8.256 &amp;&amp; echo valid || echo invalid
  invalid
  </code></pre>