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

!/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
1 Like