linux sort 使用

| |
[不指定 2010/07/16 17:54 | by 张明辉 ]
最近使用linux shell 处理文件.这里介绍两个命令:sotr和uniq。
简单举例:

1: 删除交集,不同的部分放到一个新文件中。
cat list.txt list.txt.old | sort | uniq -u > list.txt.new

2: 取出两个文件的并集,重复的行只保留一份.
cat file1 file2 | sort | uniq > file3

3: 取出两个文件的交集,只留下同时存在于两个文件中的文件.
cat file1 file2 | sort | uniq -d >file3
Tags: , , ,
工作笔记 | 评论(0) | 引用(0) | 阅读(119)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]