Solved

Linux: Specific value when using netstat

Posted on 2013-11-17
2
186 Views
Last Modified: 2013-11-17
netstat -ant | awk '{print $4}' | sed 's/.*://' | tail -n +3 | sort | uniq -c | awk '{ print "\"" $2 "\":" 555};' | tr '\n' ','

Open in new window

Instead of 555 for every item, I want the same value as this:
netstat -ant | grep 80 | wc -l

Open in new window

0
Comment
Question by:hankknight
  • 2
2 Comments
 
LVL 13

Accepted Solution

by:
duncanb7 earned 500 total points
ID: 39654626
Please try it, it will echo out "22"
netstat -ant | awk '{print $4}' | sed 's/.*://' | tail -n +3 | sort | uniq -c | awk '{ print "\"" $2 "\":" 555};' | tr '\n' ','|grep -o "555" |wc -l

is it what you want? otherwise could you write more about what result you want  from


netstat -ant | awk '{print $4}' | sed 's/.*://' | tail -n +3 | sort | uniq -c | awk '{ print "\"" $2 "\":" 555};' | tr '\n' ','

  ?
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 39654654
Thanks

Have a nice and a good weekend

Duncan
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Squid Connection Pools 3 46
Guacamole cut and paste issue 3 47
Remove a folder in Linux 9 91
Virtualizing very old guest OS 4 80
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now