Solved

Linux: Specific value when using netstat

Posted on 2013-11-17
2
184 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

757 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

16 Experts available now in Live!

Get 1:1 Help Now