Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Linux: Specific value when using netstat

Posted on 2013-11-17
2
Medium Priority
?
208 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

885 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