Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含 7 列的数据库(file.txt)。我有一个名称列表(names.txt)。我想计算 file.txt 中 names.txt 中的名称同时出现在第 3 列和第 4 列中的行数。换句话说,我不想计算名称仅出现在文件的一列中的行数。 txt 或根本不出现。我怎么能在unix中做到这一点?谢谢。
awk -F, 'BEGIN { while ((getline name < "names.txt") > 0) { names[name] = 1 } close("names.txt") count = 0 } $3 in names && $4 in names { count++ } END { print count }' file.txt