[Root @ XKWB5510 ~] # Ifconfig eth0 | awk-F "[:] +" 'nr = 2 {print $4 #/" $ NF }'
192.168.200.210/255.255.255.0
In fact, the consciousness of this sentence is:
[:] + Use multiple spaces or multiple: As Separators
Then output the values of the fourth and last columns in the second row.
Let's take a look at this decomposition.
[Root @ XKWB5510 ~] # Ifconfig eth0 | awk-F "[:] +" 'nr = 2 {print }'
Inet addr: 192.168.200.210 Bcast: 192.168.200.255 Mask: 255.255.255.0
[Root @ XKWB5510 ~] # Awk-F "[:] +" '{for (I = 1; I <= NF; I ++) print I, $ I} '<"inet addr: 192.168.200.210 Bcast: 192.168.200.255 Mask: 255.255.255.0"
1
2 inet
3 addr
4 192.168.200.210
5 Bcast
6 192.168.200.255
7 Mask
8 255.255.255.0
After removing the space before inet, it becomes the following. Obviously, multiple spaces are also a separator.
[Root @ XKWB5510 ~] # Awk 'in in {FS = "[:] +"} {for (I = 1; I <= NF; I ++) print I, $ I} '<"inet addr: 192.168.200.210 Bcast: 192.168.200.255 Mask: 255.255.255.0"
1 inet
2 addr
3 192.168.200.210
4 Bcast
5 192.168.200.255
6 Mask
7 255.255.255.0
Author's "ANLJF column"