zoukankan      html  css  js  c++  java
  • Linux 命令

    给定一个已排好序的文件,uniq 会删除重复行并将结果输出到标准输出中。uniq 通常与 sort 结合使用以删除 sort 输出内容中的重复行。

    命令格式

    uniq [OPTION]... [INPUT [OUTPUT]]

    命令参数

    -c, --count
      输出重复行列表,并且重复行前面加上其出现的次数。

    -d, --repeated
      只输出重复行。

    -f, --skip-fields=N
      忽略每行前 N 个字段。字段以空格隔开,这与 sort 类似,但不能提供参数设置可选择的字段分隔符。

    -i, --ignore-case
      比较时不区分大小写。

    -s, --skip-chars=N
      忽略每行的前 N 个字符。

    -u, --unique
      仅输出不重复行,这是默认的选项。

    -z, --zero-terminated
      以 0 字节而非新行作为行尾标志。

    -w, --check-chars=N
      只对前 N 个字符作比较。

    --help
      显示帮助信息。

    --version
      显示版本信息。

    实例

    测试文件 testfile:

    good bye
    good bye
    hello world
    hello world
    how do you do
    long time no see
    long time no see
    long time no see
    this is a test file
    this is a test file

    a) 忽略重复行。

    [huey@huey-K42JE cmdline]$ uniq testfile 
    good bye
    hello world
    how do you do
    long time no see
    this is a test file

    b) 忽略重复行,并在每行前显示重复数。

    [huey@huey-K42JE cmdline]$ uniq -c testfile 
          2 good bye
          2 hello world
          1 how do you do
          3 long time no see
          2 this is a test file

    c) 仅输出有重复的行。

    [huey@huey-K42JE cmdline]$ uniq -d testfile 
    good bye
    hello world
    long time no see
    this is a test file
  • 相关阅读:
    消息队列接口API(posix 接口和 system v接口)
    Ubuntu 安装 Eclipse C/C++开发环境
    Ubuntu下Eclipse搭建ARM开发环境
    Linux进程间通信——使用流套接字
    Linux进程间通信——使用数据报套接字
    Linux进程间通信——信号集函数
    Linux进程间通信——使用信号
    Linux进程间通信——使用匿名管道
    mappedBy的作用
    VS Code 配置 C/C++ 环境
  • 原文地址:https://www.cnblogs.com/huey/p/4852319.html
Copyright © 2011-2022 走看看