# cat file1 module1 1.1 123 module2 2.1 123 module11 module12 module1 1.1 123 module3 3.1 123 module21 module22 # ./compare.sh module1 1.1 same module3 3.1 different module21 new module22 new module2 new module11 new module12 new #!/bin/bash #Compare two files and if $1 and $2 are same, print awk 'NR==FNR{a[$1]=$2} NR>FNR &&a[$1]&&($2==a[$1]) { print $1,$2,"same"}' file1 file2 #Compare two files and if $2 are different , print awk 'NR==FNR{a[$1]=$2} NR>FNR &&a[$1]&&($2!=a[$1]) { print $1,$2,"different" }' file1 file2 #Compare two files and if $1 and $2 are same, print,didn't consider blank lines awk 'NR==FNR{a[$1]=$2} NR>FNR && (!a[$1]) { print $1,"new awk 'NR==FNR{a[$1]=$2} NR>FNR && (!a[$1]) { print $1,"new |
|