Counting with uniq

 in
Shell experts make the best of simple combinations of standard utilities. Learn one of the most common examples of using two common commands together.
______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

sort|uniq can be replaced by awk

wgshi's picture

How about we just do this

grep Jan/2004 access.log | grep foo.php |
awk '{a[$1]++}END{for(i in a)print i, a[i]}'

Re: sort|uniq can be replaced by awk

Kris's picture

He's right. It's trickier to remember, but way faster.

Free Dummies Books
Continuous Engineering

Learn:

  • What continuous engineering is
  • How to continuously improve complex product designs
  • How to anticipate and respond to markets and clients
  • How to get the most out of your engineering resources

Get your free book now

Sponsored by IBM

Free Dummies Books
Service Virtualization

Learn to:

  • Define service virtualization
  • Select the most beneficial services to virtualize
  • Improve your traditional approach to testing
  • Deliver higher-quality software faster

Get your free book now

Sponsored by IBM