Shell Uniq and sort simple usage and examples

Source: Internet
Author: User

Sort by the second character of the 1th field, if the field is only 1 characters followed by a number, the order of the letters after the normal sort of 2 characters


Repeated lines in a uniq are repeated without repeating rows, such as:

1

1

2

2


And the sort in-u to achieve uniqueness, that is, the meaning of removing duplicate rows:

1

1

2

2

And

1

2

3

1

Two kinds of


I thought for a long while to figure out, first sort of the neighboring are photographed together, and then use Uniq to show the number of adjacency

awk ' {print $} ' zzz |awk-f \ ' {print $} ' |sort-n |uniq-c

5 GBCD

2 GBCD

3 2222



awk ' {print $} ' zzz |awk-f \ ' {print $} ' |uniq-c |sort-n


1 GBCD

4 GBCD

1 GBCD

1 2222

1 GBCD

2 2222


Because in a virtual host and IDC company work, so often the site is attacked, the virtual host in the server will have multiple sites, in order to find out from the log that domain name of the network number and access traffic is too large to write the following operations.


As practical as:


Tail-f/var/log/http/access |awk ' {print $} ' zzz |awk-f \ ' {print $} ' |sort-n |uniq-c


Or


Tail-f/var/log/http/access >>ABC


Again


SORT-N ABC |uniq-c


This allows you to measure the number of visits to some domain names during a certain time period.



2009-09-01


This article is from the "Five Corners" blog, please be sure to keep this source http://hi289.blog.51cto.com/4513812/1762332

Shell Uniq and sort simple usage and examples

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.