代碼: 選擇全部
netstat -na | grep ESTABLISHED | wc -l
代碼: 選擇全部
netatat -na | awk '/^tcp/{++S[$NF]}END{for(a in S){ print a, S[a]}}'
參考資料:
https://stackoverflow.com/questions/530 ... at-command
代碼: 選擇全部
awk '
/^tcp/ ##Checking if a line starts from tcp string.
{++S[$NF]} ##Creating an array named S whose index is last column($NF) value and increasing its occurrence each time it has same index by 1.
END{ ##Starting END block of this awk code here.
for(a in S){ ##Starting a for loop which loop through S array.
print a, S[a]}} ##Printing a value and S[a] value here.
' Input_file ##Mentioning Input_file name here.