小编use*_*952的帖子

Comparing files line by line in awk with delimiter

file1:

abc|123|check
def|456|map
ijk|789|globe
lmn|101112|equator
Run Code Online (Sandbox Code Playgroud)

file2:

abc|123|check
def|456|map
ijk|789|equator
lmn|101112|globe
Run Code Online (Sandbox Code Playgroud)

EXPECTED OUTPUT:

ijk|789|equator
lmn|101112|globe
Run Code Online (Sandbox Code Playgroud)

Current awk script:

awk 'BEGIN{OFS=FS="|"} NR==FNR{a[$3]=$3;next}!($3 in a)' file1 file2

This does comparison based on array content. How to compare line by line and printing only that results.

awk shell-script text-processing join

4
推荐指数
3
解决办法
5746
查看次数

标签 统计

awk ×1

join ×1

shell-script ×1

text-processing ×1