Comparison of multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparison of multiple files
# 1  
Old 10-19-2011
Comparison of multiple files

Need a write script in bournce shell.

Compare all the file contents and need to generate a report.

Example :
Having 10 trace.log files like below

trace1.log,
trace2.log
....
trace10.log

Need to compare all the 10 files contents and provide the report as below,

Assume trace file 1,3,4,5 and 6 are same
and trace file 2,7 and 8 are same
trace file 9 and 10 are unique.

Pattern1 : trace1.log count is 5
Pattern2 : trace2.log count is 3
Pattern3 : trace9.log count is 1
Pattern4 : trace10 log count is 1

Thanks In Advance
# 2  
Old 10-19-2011
Code:
!/usr/bin/ksh
typeset -i mCnt
for mFNameA in trace*.log; do
  mCnt=0
  for mFNameB in trace*.log; do
    diff ${mFNameA} ${mFNameB} 1>/dev/null/
    mRC=$?
    if [[ "${mRC}" = "0" ]]; then
      mCnt=${mCnt}+1
    fi
  done
  echo "File <${mFNameA}> count <${mCnt}>"
done

This User Gave Thanks to Shell_Life For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk comparison using multiple files

Hi, I have 2 files, I need to use column of file1 and do a comparison on file2 column 1 and print the mismatch is file3 as mentioned below. Kindly consider that file 1 is having uniq key(column) whereas in file2 we have multiple duplicates (like 44). These duplicates should not come in... (2 Replies)
Discussion started by: grv
2 Replies

2. Shell Programming and Scripting

Comparison of files

I have the requirement I have two files cat fileA something anythg nothing everythg cat fileB everythg anythg Now i shld use fileB and compare every line at fileA and get the output as something nothing (3 Replies)
Discussion started by: Priya Amaresh
3 Replies

3. Shell Programming and Scripting

Complex comparison of 3 files

Hello to all in forum, May you experts could help me with this complex comparison please. I need to search the numbers in file1 within column3 of file2 and if found, compare column4 to NF of file2 with the lines in file3. If the column4 to NF in file2 match any of the lines in file3,... (5 Replies)
Discussion started by: Ophiuchus
5 Replies

4. Shell Programming and Scripting

Comparison of two files

Hi all I have two files which I have to compare that whetehr there is soemthing common or not body, div, table, thead, tbody, tfoot, tr, th, td, p { font-family: "Liberation Sans"; font-size: x-small; } body, div, table, thead, tbody, tfoot,... (2 Replies)
Discussion started by: manigrover
2 Replies

5. Shell Programming and Scripting

Comparison of two files (sh)

Hi, I have a problem with comparison of two files file1 20100101 20090101 20080101 20071001 20121229 file2 19990112 12 456 7 20011131 19 20100101 2 567 1 987 17890709 123 555 and, sh script needs to compare of these two files and give out to me result: 20100101 2 567 1 987 it... (5 Replies)
Discussion started by: shizik
5 Replies

6. Shell Programming and Scripting

Awk multiple variable array: comparison

Foo.txt 20 40 57 50 22 51 66 26 17 15 63 18 80 46 78 99 87 2 14 14 51 47 49 100 58 Bar.txt 20 22 51 15 63 78 99 55 51 58 How to get output using awk 20 22 57 50 51 15 26 17 63 78 80 46 99 55 - - 51 58 49 100 (5 Replies)
Discussion started by: genehunter
5 Replies

7. UNIX for Dummies Questions & Answers

multiple comparison in awk

I have an input file. Each line in it has several characters. If the first three characters of the line is '000' or '001' or '002' or '003', I need to print it in output. How can I do this in awk. I am able to do if the search string is only one (let us say 000). cat <filename> | awk... (1 Reply)
Discussion started by: paruthiveeran
1 Replies

8. Shell Programming and Scripting

Need help on comparison of two csv files

Dear All, I want to compare two csv files using shell programming - File 1 contents 44,,NONE,0,,2/2/1901 66,,NONE,0,,2/3/1901 File 2 Contents 1022,3708268,AUFX,0,100919,3/1/2006 66,,NONE,0,,2/3/1901 After comparing each column/field I want to print the occurances of... (5 Replies)
Discussion started by: sourav1982
5 Replies

9. Shell Programming and Scripting

comparison of 2 files

Kindly help on follows. I have 2 files. One file contains only one column of mobile numbers. And total records in a file 12 million. Second file contains 2 columns mobile numbers and balance. and total records 30 million. I want to find out balance of each data in file 1 corresponding to file 2.... (2 Replies)
Discussion started by: kamal_418
2 Replies

10. Shell Programming and Scripting

Comparison of two files in awk

Hi, I have two files file1 and file2 delimited by semicolon, And I want to compare column 2 and column3 of file1 to column3 and column 4 in file2. file1 -------- abc;cef;155.67;143_34; def;fgh;146.55;123.3; frg;hff;134.67;; yyy;fgh;134.78;35_45; file 2 --------- abc;cef;155.09;;... (12 Replies)
Discussion started by: jerome Sukumar
12 Replies
Login or Register to Ask a Question