您的位置:首页 > 运维架构 > Shell

shell脚本之uniq命令

2016-10-17 18:41 85 查看
uniq 
用来检查文件中重复出现的行列,并且删除重复部分。


用法:uniq [选项]... [文件]

  -c, --count           prefix lines by the number of occurrences

  -d, --repeated        only print duplicate lines, one for each group

  -D, --all-repeated[=METHOD]  print all duplicate lines

                          groups can be delimited with an empty line

                          METHOD={none(default),prepend,separate}

  -f, --skip-fields=N   avoid comparing the first N fields

      --group[=METHOD]  show all items, separating groups with an empty line

                          METHOD={separate(default),prepend,append,both}

  -i, --ignore-case     ignore differences in case when comparing

  -s, --skip-chars=N    avoid comparing the first N characters

  -u, --unique          only print unique lines

  -z, --zero-terminated  end lines with 0 byte, not newline

  -w, --check-chars=N 对每行第N 个字符以后的内容不作对照

      --help 显示此帮助信息并退出

      --version 显示版本信息并退出

若域中为先空字符(通常包括空格以及制表符),然后非空字符,域中字符前的空字符将被跳过。


常用选项说明:

– c 显示输出中,在每行行首加上本行在文件中出现的次数。

– d 只显示重复行。

– u 只显示文件中不重复的各行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell linux 脚本 uniq