Reputation: 65
I want to get a list of ports of the established connections using netstat -v grep
.
I am trying this:
sudo netstat -v | grep "ESTABLISHED" | cut -d: -f5
Any help?
Upvotes: 0
Views: 282
Reputation: 88969
Try this with $5
and $4
:
netstat -v | awk '/ESTABLISHED/ {split($5, array, ":"); print array[2]}'
Upvotes: 2
Reputation: 744
Please try
netstat -v| grep "ESTABLISHED"| awk '{print $5}' | cut -d ":" -f2
Upvotes: 1