1. 过滤a.log的重复数据

#统计
cat  datatest.log|sort|uniq -d |wc -l 
#放入b.log     
cat  datatest.log|sort|uniq -d >b.log

一、两个文件的交集、并集(前提条件:每个文件中不得有重复行)

1. 取出两个文件的并集(重复的行只保留一份)

  cat file1 file2 | sort | uniq > file3

2. 取出两个文件的交集(只留下同时存在于两个文件中的文件)

  cat file1 file2 | sort | uniq -d > file3

3. 删除交集,留下其他的行

  cat file1 file2 | sort | uniq -u > file3

 

二、两个文件合并

1. 一个文件在上,一个文件在下

  cat file1 file2 > file3

2. 一个文件在左,一个文件在右

  paste file1 file2 > file3

 

三、一个文件去掉重复的行

1. 重复的多行记为一行

  sort file |uniq

2. 重复的行全部去掉

  sort file |uniq -u

相关文章:

  • 2021-10-28
  • 2021-12-27
  • 2021-11-05
  • 2021-06-16
  • 2021-11-19
  • 2022-01-06
猜你喜欢
  • 2022-12-23
  • 2022-02-08
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案