Israel Garcia <igalva...@gmail.com> writes: >[...] it seems when the script found >duplicate lines, like named/tcp and named/udp it only show one, se >below:
>vps204:/usr/local/bin# netstat -lntup >tcp 0 0 67.212.94.125:53 0.0.0.0:* >LISTEN 23874/named >tcp 0 0 127.0.0.1:53 0.0.0.0:* >LISTEN 23874/named >tcp6 0 0 :::53 :::* >LISTEN 23874/named >udp 0 0 67.212.94.125:53 0.0.0.0:* > 23874/named >udp 0 0 127.0.0.1:53 0.0.0.0:* > 23874/named >udp6 0 0 :::53 :::* > 23874/named >And the script output: >vps204:/usr/local/bin# check2.sh >/usr/sbin/named on port 53/tcp from package bind9 (version 1:9.5.1.dfsg.P3-1) >As you can see the output only show named 53/tcp. Good catch. Change the sort in the ports_and_pids function to sort -u -t/ -k1n -k2 It should look like this now: ports_and_pids() { netstat -lntup \ | awk '/^tcp/ { print $4"/"$1, $7 } /^udp/ { print $4"/"$1, $6 }' \ | sed -n 's|^[^ ]*:\([^ ]*\) \([0-9]*\)/.*|\1 \2|p' \ | sort -u -t/ -k1n -k2 } -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org