Comparing two files issue.

more prod.properties

# remote connection details
cdr_url=http://myprod.col.net:1890/service
cdr_user=user1
cdr_pswd=pass11
boot_time=ON

more back.properties

cdr_url=http://myback.col.net:1890/service
cdr_user=user1
cdr_pswd=pass11
storage=file

I need to compare the back.properties with the prod.properties and highlight only those entries in the back.properties that are missing v/s the prod.properties & those that do not match while ignoring the comments delimiter "#" from both comparing files.

Desired output:

cdr_url=http://myback.col.net:1890/service
boot_time=ON
storage=file

I dont like the output of the diff command and i want an output like the above.

awk '/^#/ {next} FNR==NR {prod[$0];next} !($0 in prod)' prod.properties back.properties

How come that boot_time=ON is in your desired output? It shouldn't be there according to your spec.

Becoz boot_time=ON is present in the prod.properties and the team "may have" missed mentioning it in the back.properties and hence it too needs to be in the output for us to realize.

So, i need anything extra storage=file , anything missing boot_time=ON , anything different cdr_url=http://myback.col.net:1890/service from the back.properties v/s the prod.properties. I hope you can help me now ??

If the order of the output doesn't matter, this snippet might work:

awk '/^#/ {next} NR==FNR {prod[$0]=$0;next} {if ($0 in prod) { delete prod[$0] } else {print }}; END {for (i in prod) print prod}' prod.properties back.properties

I DO NOT have the bash profile !!

I tried both the suggestion on my windows unix cygwin but the command does not yield any result.

awk '/^#/ {next} NR==FNR {app_prd[$0]=$0;next} {if ($0 in app_prd) { delete app_prd[$0] } else {print }}; END {for (i in app_prd) print app_prd}' app_prd.properties app_dr.properties

awk '/^#/ {next} FNR==NR {app_prd[$0];next} !($0 in app_prd)' app_prd.properties  app_dr.properties

$ uname -a
CYGWIN_NT-6.1-WOW64 IUCLP01858 1.7.29(0.272/5/3) 2014-04-07 13:44 i686 Cygwin

The filenames i am trying to compare are app_prd.properties and app_dr.properties.

While on my unix the command fails with the below output.

$ awk '/^#/ {next} NR==FNR {app_prd[$0]=$0;next} {if ($0 in app_prd) { delete app_prd[$0] } else {print }}; END {for (i in app_prd) print app_prd}' app_prd.properties app_dr.properties
awk: syntax error near line 1
awk: illegal statement near line 1
awk: bailing out near line 1

$ awk '/^#/ {next} FNR==NR {app_prd[$0];next} !($0 in app_prd)' app_prd.properties  app_dr.properties
awk: syntax error near line 1
awk: bailing out near line 1

 uname -a
SunOS mymac 5.10 Generic_150400-09 sun4v sparc SUNW,SPARC-Enterprise-T5220

Can you help fix ?

As Don says always,