I have a file that is in the following format:
6,test,A,B,C,D
6,test,A,B,C,F
7,test,A,B,C
7,test,A,B,D
I would like to write something that outputs the different columns. For example:
6 - column 6 is different
7 - column 5 is different
Columns will always be separated by a comma and the first column will always be the unique identifier among the rows.
awk
to the rescue!
here is the prototype that works, fix the text for your needs
$ awk -F, '$1 in a{n=split(a[$1],p);
for(i=2;i<=n;i++)
if(p[i]!=$i) print $1,i " different"; next}
{a[$1]=$0}' file
6 6 different
7 5 different