Basically I want to compare column 1 from File 1 and column2 from File 2. If they match , I want to replace column 6 and column 14 of File 2 with Coulmn 2 and Column3 of File1 giving File3,
awk '
NR==FNR{ # When the first file is being read (only then are FNR and NR equal)
A[$1]=$3 # create an (associative) element in array A with the first field as the index and the 3rd field as value
B[$1]=$2 # create an (associative) element in array B with the first field as the index and the 2rd field as value
next # start reading the next record (line)
}
$2 in A{ # while reading the second file, if field 2 is present in array A (we could also have chosen B)
$6=B[$2] # then set field 6 to the element in array B with the second field as the index
$14=A[$2] # and set field 14 to the element in array A with the second field as the index
}
1 # print the record (line)
' FS=\| OFS=\| file1 file2 # Set the input and output field separator to the pipe symbol and read file 1 and then file 2