Is there a simple way to check if values in the second column of a file ( File 2) exist in the second column of another file (File 1), for example by printing a star next to the concerned line? If possible using awk.File 1A   1,2,3,4 B   15,16,17File 2A   3B   18Expected output: File 3A   1,2,3,4     *B   15,16,17         EDITWhat if File 2 looks like:A    3,8B    18,19but the expected output remains the same?
Check values in a text file
awk
Try this:$ awk '   FNR == NR {       a[$1] = $2;next   }   {       split(a[$1],b,,);       for (i in b) {           if ($2 == b[i]) {               printf(%s %s\t*\n,$1,a[$1]);               next;           }       }       print $1,a[$1];   }' file1 file2 A 1,2,3,4   *B 15,16,17UpdateWith your new input, try:$ awk '    FNR == NR {        a[$1] = $2;        next;    }    {        split($2,b,,);        split(a[$1],c,,);        for (i in b) {            if (b[i] in c) {                printf(%s %s\t*\n,$1,a[$1]);next;            }}                print $1, a[$1];     }' file1 file2