Compare 2 files with different keywords : use server health-check tool

I have two files to be compared to get the output of the differences.
File1 has a lot more lists than File2.

After searching a lot on this thread I'am unable to find the exact code that im willing to get.

This will be used as 'pre-check'/post-check utility (health check Tool) to compare some OS processes post server reboot activities.

  • I need to know if DISK or DATABASES are not up as compared to File A. The output file will show "WARNING" .
  • If the DISK and DATABASE match in both the files, It will simply show "SUCCESS"

My requirement is to differentiate the keywords (like available disks, OS processes) from File1 to File2 and get output in another file if the required keyword doesnt match.

We are able to get the output of various component (database and Disks )in different files.

PRE_Running_Database.log

DATABASE1
DATABASE5
DATABASE2
DATABASE3
DATABASE4
DATABASE6

POST_Running_Database.log

DATABASE1
DATABASE3
DATABASE4
DATABASE5

DISK_pre_check.log

DISK                                   
-------------------------                  
/dev/rprod_0032_011                        
/dev/rprod_0032_013                        
/dev/rprod_0032_015                        
/dev/rprod_0032_016                        
/dev/rprod_0032_017                        
/dev/rprod_0032_018                        
/dev/rprod_0032_019                        
/dev/rprod_0032_020                        
/dev/rprod_0032_021      

DISK_post_check.log
-------------------------

/dev/rprod_0032_011                        
/dev/rprod_0032_012                        
/dev/rprod_0032_013                        
/dev/rprod_0032_014                        
/dev/rprod_0032_015                        
/dev/rprod_0032_016                        
/dev/rprod_0032_017                        
/dev/rprod_0032_018                        
/dev/rprod_0032_019                        
/dev/rprod_0032_020                        
/dev/rprod_0032_021      

Output :

DISK :  SOME MISSING
DATABASE :  SOME NOT RUNNING

Did you consider the comm utility:

comm <(sort file1) <(sort file2)
               DATABASE1
DATABASE2
               DATABASE3
               DATABASE4
               DATABASE5
DATABASE6
2 Likes