one liner to extract ip address with last octet replaced with 0
<p>I have  Beaglebone Black based custom board,<br>
I want to extract ip address of an interface eth0 and replace fourth octet with 0.<br>
I am using below one liner for extracting ip,</p>

<pre><code>ip addr show eth0 | awk  '$1=="inet"{print $2}'
output : 192.168.2.158/24

Expected output : 192.168.2.0/24
</code></pre>

<p>however I am not able to make fourth octet 0, I thought of using function <code>gsub</code> however not able to get right combination. :(</p>

<p>I don't want more pipes in the command.</p>

<p>Any suggestion/pointers ?</p>

<p>Any other suggestion?</p>