ip a
produces bunch IP Addresses and interfaces status
With awk '/inet / {print $2}'
, I manage to get the IP and the subnet
wolf@linux:~$ ip a | awk '/inet / {print $2}'
127.0.0.1/8
10.10.0.1/24
10.10.1.1/24
wolf@linux:~$
Then, I pipe it to another awk to remove the CIDR notation.
wolf@linux:~$ ip a | awk '/inet / {print $2}' | awk -F / '{print $1}'
127.0.0.1
10.10.0.1
10.10.1.1
wolf@linux:~$
Is it possible to do this without piping the awk output to another awk?
Desired Output
wolf@linux:~$ ip a | <awk syntax here without additional piping>
127.0.0.1
10.10.0.1
10.10.1.1
wolf@linux:~$
cut -f 1 -d /
which could be more easily understood by the next reader of your code.