Linux under the command sort, uniq

First, use the sort command

      1. Role: the Sort command name means, it can help us to sort, and can be sorted according to different data types. Such as digital text and sort of not the same, sort can specify different options so that different sort, sort affect the results.

      2. Options:

    -f: ignoring differences of case, for example, A is considered as a same coding;

    -b: Ignore the front part of the space;

    -M: the name of the month to be sorted, sorting method e.g. JAN, DEC or the like;

           -n: Use "pure digital" sort (the default is to sort of character type);

    -r: reverse sequencing

    -u: uniq, the same data, appear only on behalf of his party

    -t: delimiter, the default is [Tab] key segmenting;

    -k: mean interval at which to sort of;

      3. Examples

         Example: the user login system recently ordered by the name of lexicographical

         Command: the WHO | the Sort -t '' -k 1

     Output:

andre pts/18 2016-09-24 16:39 (211.71.66.211)
bl :2004 2016-09-12 10:15 (211.71.66.80)
bl pts/13 2016-09-12 10:17 (:2004.0)
lmt :2006 2016-07-13 22:40 (211.71.66.202)
mj pts/10 2016-09-25 08:22 (211.71.66.191)
xiaobing :2002 2016-07-04 22:02 (211.71.66.202)
xiaobing :2003 2016-07-21 14:52 (211.71.66.70)
xiaobing pts/4 2016-07-21 09:31 (:2002.0)
xiaobing pts/6 2016-07-06 10:37 (:2002.0)

First, use the uniq command   

      1. Role: deduplication data

      2. Options:

      -i: Ignore different case characters

      -c: count the

      3. Examples

         Example: To count last logged into the system 10 and the number of users logged in

          命令:last -10 | head -9 | cut -d ' ' -f 1 | sort | uniq -c

          Output:

1 andre
1 lmt
2 mj
5 zmm

Guess you like

Origin www.cnblogs.com/vs-kaka/p/11266788.html