uniq命令使用方法
2024-10-08 20:31:40
uniq命令的作用:显示唯一的行,对于那些连续重复的行只显示一次!
接下来通过实践实例说明:
[root@stu100 ~]# cat test boy took bat home boy took bat home girl took bat home dog brought hat home dog brought hat home dog brought hat home
看test文件的内容,可以看到其中的连续重复行
[root@stu100 ~]# uniq test
boy took bat home
girl took bat home
dog brought hat home
uniq命令不加任何参数,仅显示连续重复的行一次
[root@stu100 ~]# uniq -c test boy took bat home girl took bat home dog brought hat home
-c 参数显示文件中每行连续出现的次数。
[root@stu100 ~]# uniq -d test boy took bat home dog brought hat home
-d选项仅显示文件中连续重复出现的行。
[root@stu100 ~]# uniq -u test girl took bat home
-u选项显示文件中没有连续出现的行(去除重复)。
[root@stu100 ~]# uniq -f -s test boy took bat home
-f(跳过的字段)和-s(跳过的字符数)选项忽略每行的前2个字段,忽略第二个空白字符和第三个字段的首字符(从跳过的字段数开始算起,与-f选项配合使用),结果at home
[root@stu100 ~]# uniq -f test boy took bat home dog brought hat home
-f选项忽略每行的第一个字段,这样boy ,girl开头的行看起来是连续重复的行。
lxy@lxy-e440:~$ uniq -w test.txt boy took bat home girl took bat home dog brought hat home lxy@lxy-e440:~$ uniq -w -u test.txt girl took bat home lxy@lxy-e440:~$ uniq -w -d test.txt boy took bat home dog brought hat home
-w选项对每行第N 个字符以后的内容不作对照
最新文章
- 【容器云】十分钟快速构建 Influxdb+cadvisor+grafana 监控
- 更改pip源至国内镜像,显著提升下载速度(转载)
- git workflow
- 日志时间格式有s,ms,us,如何排序最大10行
- C#的循环语句练习
- json数组和List转换
- webstrom插件:如何设置才能让webstrom能提示bootstrap的语法
- Project Euler 81:Path sum: two ways 路径和:两个方向
- PHP获取当前时间的毫秒数(yyyyMMddHHmmssSSS)
- Struts2中将.action改为.do
- 可以通过Action来判断是什么操作触发了事件
- Programming C#.Inheritance and Polymorphism
- vm lxc
- poptest老李谈分布式与集群 2
- 【Linux学习笔记】关于ubuntu开机菜单栏和任务栏不见了的有效解决方法
- Tomcat版本对照表
- 【iCore4 双核心板_uC/OS-II】例程四:软件定时器
- TCP、UDP网络通信
- 【uoj5】 NOI2014—动物园
- CloudFlare防护下的破绽:寻找真实IP的几条途径
热门文章
- 吴裕雄--天生自然TensorFlow高层封装:Keras-返回值
- Debian8.8下的VIM的配置文件
- Kubernetes系列:故障排查之Pod状态为CreateContainerError
- Java实现生产与消费(完美注释版)
- centos6.8 yum安装mysql 5.6
- 大道至简伪代码读后感java为代码形式
- js几个常用的弹层
- [LC] 1002. Find Common Characters
- F. Maximum Weight Subset(贪心or树形dp解法)
- discount the possibility|pessimistic|bankrupt|