recv的tcp最后二十位的端口连接情况
cat recv_tcp.sh #!/bin/bash while [ true ]; do /bin/sleep 1 DATE=`date +%Y/%m/%d-%H:%M:%S` netstat -anp |grep tcp | tail -20 | grep -v sshd |awk -vb=$DATE '{print b"\t"$4"-"$5"\t"$2}' >> /data/sh/recvd_tcp.txt done
recv的udp最后二十位的端口连接情况
#!/bin/bash while [ true ]; do /bin/sleep 1 DATE=`date +%Y/%m/%d-%H:%M:%S` netstat -anp | grep udp |grep -v ntp |awk -vb=$DATE '{print b"\t"$4"\t"$2}' >> /data/sh/recvd_udp.txt done
-v是赋值变量的含意,把$date的变量赋值给b
print b 输出b \t 想当于输出一个tab健的空