awk比较两个文件中多列相同或者不同的行

http://stackmirror.caup.cn/page/rhoezkk0vghd

awk -F, 'NR==FNR{ arr[$2]=$2 $1; next } 
    { print $0, (arr[$2]==$2 $3?"ok":"nok") }' OFS=, def.txt data.txt
d1,40,gold,ok
d2,30,silver,ok
d3,20,bronze,ok
d4,10,iron,ok
d5,5,wood,ok
d6,20,gold,nok
d7,10,wood,nok
d8,5,gold,nok
d9,10,silver,nok
awk 'NR==FNR{a[$2,$3];next} ($2,$3) in a' file1 file2

 

你可能感兴趣的:(Bash)