linux 删除一行中的前几个字符


netstat -an -t | grep ":3306"
tcp        0      0 :::3306                     :::*                        LISTEN     
tcp        0      0 ::ffff:192.168.0.128:3306   ::ffff:192.168.1.203:58468  ESTABLISHED
tcp        0      0 ::ffff:192.168.0.128:3306   ::ffff:192.168.0.88:65460   ESTABLISHED
tcp        0      0 ::ffff:192.168.0.128:3306   ::ffff:192.168.1.203:57018  ESTABLISHED
tcp        0      0 ::ffff:192.168.0.128:3306   ::ffff:192.168.0.88:65458   ESTABLISHED
tcp        0      0 ::ffff:192.168.0.128:3306   ::ffff:192.168.0.88:65459   ESTABLISHED
tcp        0      0 ::ffff:192.168.0.128:3306   ::ffff:192.168.0.88:65457   ESTABLISHED


#netstat -an -t | grep ":3306" | grep ESTABLISHED | awk ‘{printf "%s %s\n",$5,$6}‘ 

::ffff:192.168.1.43:49706 ESTABLISHED
::ffff:192.168.2.8:52177 ESTABLISHED


---方法1:
# netstat -an -t | grep ":3306" | grep ESTABLISHED | awk ‘{printf "%s %s\n",$5,$6}‘  |sed  ‘s/^::ffff://‘

192.168.1.43:49706 ESTABLISHED
192.168.2.8:52177 ESTABLISHED

---方法2:
# netstat -an -t | grep ":3306" | grep ESTABLISHED | awk ‘{printf "%s %s\n",$5,$6}‘ |cut  -c 8-
192.168.1.43:49706 ESTABLISHED
192.168.2.8:52177 ESTABLISHED

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。