【发布时间】:2023-03-10 16:21:01
【问题描述】:
在使用 awk 时遇到了一些问题。我有两个文件,我正在尝试用第一个文件读取第二个文件的列并提取所有匹配项。
文件1:
1
2
3
4
5
文件2:
apples peaches 3
apples peaches 9
oranges pears 7
apricots figs 1
预期输出:
apples peaches 3
apricots figs 1
awk -F"|" '
FNR==NR {f1[$1];next}
($3 in f1)
' file1 file2 > output.txt
【问题讨论】:
-
你为什么有
-F"|"?
标签: awk