Test Result Analysis script – find common messages
#!/bin/bash
#  jm - 25jan2018 - ATA info extract from test reports
####################################################################################
for x in `ls ??.txt`    #  for each report find the ATA chapters listed
   do
    Y=`echo $x | cut -c 1-2`
       ### NOTE:  drop the suffix: .txt - cut first two characters to use for new filename
  cat $x | grep Mainten | grep - | awk '{print $4}' | sort | uniq | grep -v ^$   > $Y-rpt
       ### NOTE: grep for key term, qualify with "-", print values in field 4, sort, drop dups and blank lines
   done
####################################################################################
 comm -12 01-rpt 02-rpt | comm -12 - 03-rpt | comm -12 - 04-rpt | \
comm -12 - 05-rpt | comm -12 - 06-rpt | comm -12 - 07-rpt | \
comm -12 - 08-rpt | comm -12 - 09-rpt | comm -12 - 10-rpt > common-messages.txt
####################################################################################
 for z in `cat common-messages`
    do
    grep $z ??.txt              >>       status-ATA-designator-`date +%d%b%y`.txt
    echo "===========" >>       status-ATA-designator-`date +%d%b%y`.txt
    grep -A 15 $z ??.txt      >> DETAILS-ATA-designator-`date +%d%b%y`.txt
    echo "===========" >> DETAILS-ATA-designator-`date +%d%b%y`.txt
    done
####################################################################################
##  first grep gets the line with the ATA chapter, 2nd grep read 15 lines AFTER - to see details
##  the echo inserts a divider between messages for reading clarity
####################################################################################