file1:
SA, 5006, 12, , DJ
CN, BN, , BBB, 13
22, 67, GG, FF, 88
33, BB, AA, CC, 22
file2:
SA, 5006, 12, 15 , DJ
CN, BN, , BBB, 13
empty line
33, CC, AA, dd, 22
output:
SA, 5006, 12, 15 , DJ, unmatch, 4
CN, BN, , BBB, 13, match
empt, empt, empt, empt, empt, unmatch, 12345
33, CC, AA, dd, 22, unmatch, 24
I need to compare two .csv files line by line, but some of field/lines can be empty and output should be in file3: 5 columns form file 2, match\unmatch, unmatch Fields like this:
c1, c2, c3, c4, c5, match/unmatch, concatenation of digits representing unmatch fields.
I try something but I new with awk can anyone help? :)
code that I use, but I think the problem its empty fields anf I dont know How I can print the :
##Set input and output field separators to ':'.
BEGIN {
FS = OFS = ":"
}
NR == FNR {
## save all the line in an array, so lines will be saved like:
## c1::c2::c3::c4::c5
++a[$0]
## Process next line from the beginning.
next
}
## for every line of second file.
{
## Search for the line in the array, if not exists it means that any field is different
## print the line.
if ( !a[$0] ) {
$6 = "same"
print
}else {
$6 = " not same"
print
}
}
... unmatch, 2instead of24?:when the file uses,?ddin the output and notCC? Should the output contain lines from file1 or file2?