>_ IzzyLab

Topic breakdown

Each network interface has its own set of addresses, shown by the ip utility from the iproute2 package. The inet line holds the IPv4 address together with the prefix length after a slash (/16) — these are two different pieces of information: the address itself and the subnet mask. To get only the address, the command's output needs to be parsed: pull out the right field and cut off everything after the /. The -o flag (one line per record) and text filters like awk/cut come in handy.

What's checked

  1. /root/ip.txt has the eth0 address without the mask

What it looks like