我有这个 2 csv 文件
旧的.csv
station,32145,80
station,32145,60
新的.csv
station,32145,80
station,32145,801
期待结果
结果.csv
station,32145,80,no change
station,32145,801,new
station,32145,60,Delete
我已经使用diff
并awk
完成了这项工作,但我有一个小问题。该行没有更改或删除的行已正确更新,但新行未正确更新。任何人都可以告诉我我的错误在哪里?
diff -W999 --side-by-side old.csv new.csv |
awk '/[|][\t]/{split($0,a,"[|][\t]");print a[2]" No Change"};/[\t] *<$/{split($0,a,"[|][\t]* *<$");print a[1]" Delete"};/>[\t]/{split($0,a,">[\t]");print a[2]" New"}'