awk usage

 ip addr|awk '/inet /{gsub(/\/.*/," " ,$2);print $2}'

ip addr displays the local ip address

 

awk中'/inet/{gsub (/\.*/," ",$2);print $2}'

 

 

Match a line containing inet spaces, and replace the characters in/after the second field in the matched line with spaces, and then print the second field

The gsub function is equivalent to the sed command sed 's///g' in bash

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324980121&siteId=291194637
awk