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