nev*_*int 4 unix linux comm set-operations
鉴于这两个文件:
$ cat A.txt $ cat B.txt
3 11
5 1
1 12
2 3
4 2
Run Code Online (Sandbox Code Playgroud)
我想在B中找到A"BUT NOT"中的行号.什么是unix命令?
我试过这个,但似乎失败了:
comm -3 <(sort -n A.txt) <(sort -n B.txt) | sed 's/\t//g'
Run Code Online (Sandbox Code Playgroud)
Alo*_*hal 10
comm -2 -3 <(sort A.txt) <(sort B.txt)
Run Code Online (Sandbox Code Playgroud)
如果我理解正确的话,应该做你想做的事.
编辑:实际上,comm需要按字典顺序对文件进行排序,因此您不需要-n在sort命令中:
$ cat A.txt
1
4
112
$ cat B.txt
1
112
# Bad:
$ comm -2 -3 <(sort -n B.txt) <(sort -n B.txt)
4
comm: file 1 is not in sorted order
112
# OK:
$ comm -2 -3 <(sort A.txt) <(sort B.txt)
4
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2008 次 |
| 最近记录: |