1-е решение: С простым awk
.
awk 'FNR==NR{a[FNR]=$0;next} a[FNR]==$0{print;next} {print ""}' file1 file2
ИЛИ согласно комментарию сэра анубхавы:
awk 'FNR==NR{a[FNR]=$0;next} a[FNR]!=$0{$0=""} 1' file1 file2
Объяснение: Добавление подробного объяснения для вышеуказанного кода.
awk ' ##Starting awk program from here.
FNR==NR{ ##Checking condition FNR==NR which will be TRUE when first file Input_file1 is being read.
a[FNR]=$0 ##Creating an array a with index FNR and value of current line here.
next ##next will skip all further statements from here.
}
a[FNR]==$0{ ##Checking condition if value of array a with FNR index and current line is equal then do following.
print $0,a[FNR] ##Printing current line and value array a with index FNR here.
}
' file1 file2 ##Mentioning Input_file names here
2-е решение: Учитывая, что ваши фактические Input_file (s) имеют только 2 столбца в соответствии с показанными образцами, не могли бы вы попробовать затем выполнить следующее.
paste Input_file1 Input_file2 | awk '$1==$2{print $1};$1!=$2{print ""}'
Этот код будет печатать только те строки, значения которых равны в Input_file1 и Input_file2.