We tested this process with three reports.
--> cat 01.txt |
grep Mainten | grep - | awk '{print $4}' | sort > 01-rpt
The awk command will find patterns between delimiters. A space
is a default delimiter.
In the string above we are printing the 4th field, the string
we found with grep looked like this:
[] Maintenance Message: 21-18891 ACTIVE
The first field is the "brackets", second
"Maintenance", third " Message:", and fourth, our
numbers.
# NOTE: at this point the three files were created with
Maintenance codes only listed
# -rw-r--r-- 1 luser users 486 Sep 19 14:17 1-rpt
# -rw-r--r-- 1 luser users 414 Sep 19 14:18 2-rpt
# -rw-r--r-- 1 luser users 1143 Sep 19 14:18 3-rpt
Once the 3 files were intially used to create
the Maint code list test report, then we used the "compare" command to
compare the 3 (or more) reports: (comm - compare two sorted files line by line)
--> comm -12
1-rpt 2-rpt | comm -12 - 3-rpt > common-messages.txt
Then we look at our common messages in the file...
in the example below we saw 7 common messages across all three
of the reports. # NOTE: testing output:
--> cat common-messages.txt
# 24-19405
# 30-32702
# 30-32703 …
#
Then we used grep ( global regular expression
- print lines matching a pattern ) to find WHICH of the filtered files had
those codes...we used grep on
each of the original files to find the reports which lead us back to the
messages. TESTING:
--> grep 24-19405 *
# 1-rpt:24-19405
# 2-rpt:24-19405
# 3-rpt:24-19405
# common-messages.txt:24-19405
# XX_YY_B-7839_2016-07-28_21.38.57Z.txt: [] Maintenance
Message: 24-19405 ACTIVE
# XX_YY_AP432A_2016-07-28_21.06.45Z.txt: [] Maintenance
Message: 24-19405 ACTIVE
# XX_SPTEST465_2016-05-18_07.46.58Z.txt: [] Maintenance
Message: 24-19405 ACTIVE
# ------------------------------------------------