Awk- Compare Numbers from Two Files and write Differences in New File
4
votes
4
answers
407
views
I have two lists with item numbers and want to mark the difference between these lists by writing the numbers wich aren't in both files in a new file.
Both Files have the item number in column 2 and part ID in column 3.
First I want to check if the item number in file 1 exists , if so the part ID has to be checked and if it's true, go to the next item number. Otherwise, if one of the conditions isn't true the difference should be written in a new created file. In case that a item number is only in one of the two files the program should write "Artikel[x] cannot be found".
EXAMPLE
FILE 1
Artikel[ 456]= 1,2
Artikel[ 877]= 3
Artikel[ 278]= 4
Artikel[ 453]= 13
FILE 2
Artikel[ 456]= 2, 1
Artikel[ 877]= 3, 5
Artikel[ 387]= 4, 9, 4
Artikel[ 947]= 10
OUTPUT
Artikel[ 877]= 3 != Artikel[ 877]= C3, C5
Artikel[ 278]= 4 != Artikel[ 278 ]= 4, 9, 4
Artikel[ 453]= 13 cannot be found in File 2!
Artikel[ 947]= 10 cannot be found in File 1!
I thought i could do this with writing the item number from File 1 in an array and just check every line in File 2 but somehow I am struggling to manage that. I would appreciate any help.
Thanks
Asked by user596594
Dec 18, 2023, 10:26 AM
Last activity: Jan 19, 2024, 12:37 PM
Last activity: Jan 19, 2024, 12:37 PM