官术网_书友最值得收藏!

The uniq command

The following are a few examples showing the usage of the uniq command:

  • This command removes duplicate adjacent lines from the file:
    $ cat test
    aa
    aa
    cc
    cc
    bb
    bb
    yy
    zz
    $ uniq test
  • This output removes the duplicate adjacent lines from test file, shown as follows:
    aa
    cc
    bb
    yy
    zz
  • The next command only prints duplicate lines:
    $ uniq -d test
  • Output:
    aa
    cc
    bb
  • The following command prints the number of occurrences of all elements on an inpidual line:
    $ uniq -c test
  • Output:
    2 aa
    2 cc
    2 bb
    1 yy
    1 zz
主站蜘蛛池模板: 兴义市| 乳山市| 黎城县| 正蓝旗| 孟村| 施秉县| 公安县| 永和县| 上林县| 厦门市| 洛南县| 绥滨县| 阿拉尔市| 淮北市| 奎屯市| 依兰县| 恩平市| 奇台县| 和林格尔县| 大港区| 郴州市| 屯门区| 小金县| 宝应县| 北海市| 阿拉善右旗| 德钦县| 体育| 内黄县| 邵阳市| 仲巴县| 门源| 滦南县| 天祝| 大埔区| 易门县| 布尔津县| 麦盖提县| 宾阳县| 集安市| 康平县|