Bash - Deleting the same lines in two CSV files

I have two CSV files - nodes.csv and edge.csv - where the columns are tab delimited. I removed some lines in node.csv using

awk -F'\t' -i inplace '($3 != "Symbol")' nodes.csv

      

How do I remove matching lines in edge.csv?

For example, in nodes.csv I have:

ANR 35755   ParameterType   uint32_t
CYP 35756   Identifier      status
ANR 35757   CFGEntryNode    ENTRY
ANR 35758   CFGExitNode     EXIT
ANR 35759   Symbol          * host
CYP 35760   Symbol          * irq_status_bits
ANR 35761   Symbol          irq_status_bits

      

And in edge.csv I have:

35738   35758   FLOWS_TO
35689   35759   USE
35701   35759   USE
35727   35760   USE
35734   35760   USE
35727   35761   USE
35735   35761   USE

      

I need to delete rows 5,6,7 in nodes.csv

because column 3 has a value character. How to delete lines 5,6,7 in edges.csv

?

Output: nodes.csv

ANR 35755   ParameterType   uint32_t
CYP 35756   Identifier      status
ANR 35757   CFGEntryNode    ENTRY
ANR 35758   CFGExitNode     EXIT

      

edges.csv

:

35738   35758   FLOWS_TO
35689   35759   USE
35701   35759   USE
35727   35760   USE

      

Many thanks!

+3


source to share


1 answer


awk -F'\t' -i inplace 'NR==FNR{if ($3 != "Symbol") a[NR]} FNR in a' nodes.csv edges.csv

      



0


source







All Articles