title: How to retrieve only the IPV4 from ip addr in Linux
body: <p>I am trying to pass the IPV4 for the <code>tun0</code> interface into a script.</p>
  <pre><code>./start.sh `ip addr | grep tun0 | grep inet`
  </code></pre>
  <p>The issue I have is I cannot think how to separate this further to only get <code>10.10.14.252</code>.</p>
  <pre><code>inet 10.10.14.252/23 scope global tun0
  </code></pre>
  <p>Any help appreciated to perhaps use <code>sed</code> to retrieve only the <code>10.10.14.252</code>. The IPV4 is dynamic, the script can be executed on any environment and may not always start with <code>10.10</code></p>
  <pre><code>ip addr | grep tun0|grep inet|tr ' ' &quot;\n&quot;|grep 10.|tr '/' &quot;\n&quot;|grep 10
  </code></pre>
  <p>This works, its long but works. But am I guaranteed that the IPV4 will always start with 10?</p>