Linux Shell脚本入门--Uniq命令
uniq
uniq命令可以去除排序过的文件中的重复行,因此uniq经常和sort合用。也就是说,为了使uniq起作用,所有的重复行必须是相邻的。
uniq语法
[root@www ~]# uniq [-icu]
选项与参数:
-i :忽略大小写字符的不同;
-c :进行计数
-u :只显示唯一的行
testfile的内容如下
cat testfile
hello
world
friend
hello
world
hello
直接删除未经排序的文件,将会发现没有任何行被删除
#uniq testfile
hello
world
friend
hello
world
hello
排序文件,默认是去重
#cat words | sort |uniq
friend
hello
world
排序之后删除了重复行,同时在行首位置输出该行重复的次数
#sort testfile | uniq -c
friend
hello
world
仅显示存在重复的行,并在行首显示该行重复的次数
#sort testfile | uniq -dc
hello
world
仅显示不重复的行
sort testfile | uniq -u
friend
Linux Shell脚本入门--Uniq命令的更多相关文章
- Linux Shell脚本入门:tee命令
用途说明 在执行Linux命令时,我们可以把输出重定向到文件中,比如 ls >a.txt,这时我们就不能看到输出了,如果我们既想把输出保存到文件中,又想在屏幕上看到输出内容,就可以使用tee ...
- Linux Shell脚本入门--cut命令
Linux Shell脚本入门--cut命令 cut cut 命令可以从一个文本文件或者文本流中提取文本列. cut语法 [root@www ~]# cut -d'分隔字符' -f fields &l ...
- Linux Shell脚本入门--wget 命令用法详解
Linux Shell脚本入门--wget 命令用法详解 wget是在Linux下开发的开放源代码的软件,作者是Hrvoje Niksic,后来被移植到包括Windows在内的各个平台上.它有以下功能 ...
- Linux Shell 脚本入门
linux shell 脚本格式 #!/bin/sh#..... (注释)命令...命令... 使用vi 创建完成之后需设置权限 chmod +x filename.sh 执行命令: ./filena ...
- Linux shell 脚本入门教程+实例
原文:http://www.wiquan.com/article/136 为什么要进行shell编程 在Linux系统中,虽然有各种各样的图形化接口工具,但是shell仍然是一个非常灵活的工具.She ...
- Linux Shell脚本入门--(linux空设备文件和重定向)>/dev/null 2>&1
linux空设备文件和重定向 输出/输入重导向 > >> < << :> &> 2&> 2< ...
- Linux Shell脚本入门--grep命令详解
grep简介<摘自鸟哥,并加以整理.> grep (global search regular expression(RE) and print out the line,全面搜索正则表达 ...
- Linux Shell脚本入门--awk命令详解
简单使用: awk :对于文件中一行行的独处来执行操作 . awk -F :'{print $1,$4}' :使用‘:’来分割这一行,把这一行的第一第四个域打印出来 . 详细介绍: AWK命令介绍 ...
- Linux Shell脚本入门--wc命令
wc 统计文件里面有多少单词,多少行,多少字符. wc语法 [root@www ~]# wc [-lwm] 选项与参数: -l :仅列出行: -w :仅列出多少字(英文单字): -m :多少字符: 默 ...
随机推荐
- HOWTO: 为GitHub for Windows指定代理服务器(转)
If the command line way of configuring your proxy server doesn't work, you can probably just edit .g ...
- Maven: NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher
为了和团队开发环境保持一致,须要 在Ubuntu上安装maven2.2.1,引文我之前已经用apt-get命令安装了3.3的maven.在运行maven命令时报错: Maven: NoClassDef ...
- urlrewrite使用地址重写
地址重写: 主要是为了站点的安全. 比如我们平时的地址请求 地址重写前,訪问路径是: /read.egov?action=read&bid=2 地址重写后,訪问路径是:/read-read-2 ...
- 我的2011年总结--大明zeroson程序猿一周年总结
花絮:看到csdn举办"我的2011"年度征文活动,我恰好工作也一年多了,上个月写了篇博客,主要是我换工作方面的流水账,这篇我从主观.客观.多方位地谈谈我这一年的变化. ...
- POJ 2411 Mondriaan's Dream (dp + 减少国家)
链接:http://poj.org/problem?id=2411 题意:题目描写叙述:用1*2 的矩形通过组合拼成大矩形.求拼成指定的大矩形有几种拼法. 參考博客:http://blog.csdn. ...
- Hadoop Streaming 得到mapreduce_map_input_file中遇到的问题的版本号
1.Hadoop Streaming,您可以在任务获得hadoop设置环境变量, 例如,使用awk书面map从而能获得:filename = ENVIRON["mapreduce_map_i ...
- Android - 采用ApiDemos得知Android开展
采用ApiDemos得知Android开展 本文地址: http://blog.csdn.net/caroline_wendy 位置: android-sdk/samples/android-20/l ...
- SettingsProvider 它SettingsCache
转载请注明出处:http://blog.csdn.net/droyon/article/details/35558437 SettingsCache,如指出,SettingsProvider缓冲.这将 ...
- java json字符串转List、Map等对象
List<Map<String, Object>> map = g.fromJson(jsonStr, new TypeToken<List<Map<Stri ...
- 移植X264成功
http://blog.csdn.net/mashang123456789/article/details/8673426 http://blog.csdn.net/b5w2p0/article/de ...