在”a b c d”的b后面插入3个字段e f g
echo a b c d|awk ‘{$3="e f g "$3}1‘
获取ipv4地址:
方法一:
ifconfig | awk ‘/inet / && !($2 ~/^127/){print $2}‘
方法二:
ifconfig | awk ‘BEGIN{RS=""} !/^lo/{print $6}‘
方法三:
ifconfig | awk ‘BEGIN{RS="";FS="\n"}!/lo/{$0=$2;FS=" ";$0=$0;print $2;FS="\n"}‘