Linux 两个文件取并集、交集、差集
Linux sort uniq 大约 347 字有文本1.txt
,内容如下:
a
b
c
x
y
z
有文本2.txt
,内容如下:
a
x
m
n
并集 - uniq
sort 1.txt 2.txt | uniq
输出:
a
b
c
m
n
x
y
z
交集 - uniq -d
sort 1.txt 2.txt | uniq -d
输出:
a
x
差集 - uniq -u
取1.txt
的差集
sort 1.txt 2.txt 2.txt | uniq -u
输出:
b
c
y
z
取2.txt
的差集
sort 1.txt 2.txt 1.txt | uniq -u
输出:
m
n
特别注意
需关注两个文件的文件格式,必须一致,否则会出现问题。博主因为两文件格式问题,花费半天时间。
阅读 4402 · 发布于 2019-08-26
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
JavaScript 获取本地局域网 IP 地址阅读 6904
-
macOS 更改默认打开方式阅读 296
-
Go 中的注释阅读 1804
-
Java8 @FunctionalInterface 注解阅读 1581
-
PHP 压缩 HTML 代码阅读 1625
-
Git 命令之查看及设置用户名邮箱阅读 3263
-
skaffold init 提示 one or more valid Kubernetes manifests are required to run skaffold阅读 933
-
Ubuntu 使用 Certbot 给 Nginx 添加 SSL 证书阅读 2081
-
使用 Telepresence 在本地环境直接访问 Kubernetes 内部服务地址阅读 934
-
Spring Boot Slf4j MDC 实现全链路日志追踪阅读 974