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

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
主站蜘蛛池模板: 开鲁县| 湄潭县| 东乌珠穆沁旗| 中江县| 泰来县| 百色市| 革吉县| 遂昌县| 无锡市| 福海县| 奉化市| 盐亭县| 醴陵市| 开阳县| 临夏县| 靖州| 扎兰屯市| 涡阳县| 安吉县| 怀宁县| 古田县| 慈利县| 新宁县| 连南| 巩留县| 七台河市| 黑山县| 吴旗县| 潼关县| 丹江口市| 沈阳市| 珠海市| 基隆市| 大竹县| 定南县| 巧家县| 石狮市| 大新县| 赤壁市| 宁安市| 三台县|