I am preparing a script to check the configuration of the db2 against the standard configuration. I am fetching the output in file A and want to compare it with the standard output written in file B.

File A

Diagnostic error capture level              (DIAGLEVEL) = 3
Audit buffer size (4KB)                  (AUDIT_BUF_SZ) = 0

File B

Diagnostic error capture level              (DIAGLEVEL) = 3
Audit buffer size (4KB)                  (AUDIT_BUF_SZ) = 1000

Want awk to compare the rows and print if the complete row is not matched. eg for above want output like :

Audit buffer size (4KB)                  (AUDIT_BUF_SZ) = 0  **Not standard**



Try this,

  awk 'FNR==NR{i[$0];next}!($0 in i)' file2 file1
  Audit buffer size (4KB)                  (AUDIT_BUF_SZ) = 0
  • i[$0] To match the complete line.
  • !($0 in i) will compare and prints the line which is not matched with FileA
  • Hi Siva, how to calculate percentage here? Suppose I get 15 rows in the awk output and I want to get the percentage against fixed number 85 i.e 15/85*100 – user306751 Aug 24 '18 at 18:58
  • I get into a problem,awk 'FNR==NR{i[$0];next}!($0 in i)' file2 file1 this is perfect but i want awk to read 1 row of first file and match with 1 row of 2nd file and if different then print the whole line else no and so on row to row match. How to modify command for that? Can we do this? – user306751 Aug 24 '18 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.