uniq -c issue

Posted on 2011-09-08
Last Modified: 2012-06-27
Let me try this again..

I have the following:
sed -n "s/ns1://g;s/:ns1//g;/signin xmlns/,/signin/p;/\<signin.*/,/<\/signin>/{/\<orgName>/s/\<orgName><*/orgName>/};{/\<userName>/s/\<userName>[^m][^o][^n][^i][^t][^o][^r][^A][^c][^c][^t][^<]*/userName>/};{s/\<orgName>/<\/orgName>/}" "Apache_log" | gawk "/orgName/" { print substr($1,10,length($1)-19) }"|sort|uniq -c

Open in new window

Which works great..

However, I am wanting to change the output of uniq -c from:



Question by:Kent Dyer
  • 2
LVL 48

Accepted Solution

Tintin earned 500 total points
Comment Utility

uniq -c | sed "s/\([0-9]\) /\1,/"

Open in new window

LVL 17

Author Closing Comment

by:Kent Dyer
Comment Utility
Awesome!  Now, just need to figure out to get the top 5 lines..

gawk "/orgName/ { print substr($1,10,length($1)-19) }"  logfile | sort | uniq -c | gawk "{ print $2,$1}" | sed "s/\([0-9]\) /\1,/" | sort -r -n

Open in new window

And this now works, but now I need to just show the top five counts from the results.
LVL 17

Author Comment

by:Kent Dyer
Comment Utility
Duh..  head -30 should do the trick.



Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

13 Experts available now in Live!

Get 1:1 Help Now