An Awk solution:
Awk script file checklists.awk:
#! /usr/bin/awk -f
NR == FNR {
# Recording first input script file (for you, IDList2)
hash[$1] = $0
next
}
$1 in hash {
# if second file key is found in first file
print hash[$1]
next
}
{
# if second file key is not found in first file
print $1 > OUTPUT_FILENAME_NOT_FOUND
}
Change script execution modes:
chmod 755 checklists.awk
Awk script executed like that:
./checklists.awk -v OUTPUT_FILENAME_NOT_FOUND="./Output2" IDlist2 IDlist1 > ./Output1
Warning, "IDlist2" file (the reference), is the first data file for Awk script.
commofgrep -f, but without an example input and desired output, we can't really know.IDlist2appears inIDlist1. May we assume it's always so? (3) In your example the lines inIDlist1are unique. May we assume it's always so? (4) In your example the lines inIDlist2are unique. May we assume it's always so? (5) You wrote "match/exist". Should we assume fixed strings, not patterns (like ingrep -F)?