Thank you for the pointer Ed.
Need to process massive list of files.
The part I'm interested in a string. (Note one or more of the strings may not exist in the current logs, they only report if there is an error).
Which is why I search for string and then by error strings. Actually the logs are much longer with date and time info, which is not needed for this example.
Ff bb Change: [2:0:1] ALPA (0x13211) Port WWN (c37076082034003d) Le Fg Count changed by (3) (8 - 5) St Lf Count changed by (11) (57 - 46) Pz Sq Ed Count changed by (2) (7 - 5) Ip Tp Wq Count changed by (52) (212 - 160)
What I need to do is:
Ff bb Change: [2:0:1] which is the port, so need just 2:0:1, I need to keep the errors on the line with the port reporting it.
Also need Port WWN (c37076082034003d) so I know who is reporting the error and what errors, like Le Fg Count changed by (3) or St Lf Count changed by (11)
Output needed would look like:
If the error is Le Fg Count changed by (3) (8 - 5), on port 2:0:1 from WWN c37076082034003d. I want the output to be
2:0:1 c37076082034003d 3
Then I can use this output to sort by 2:0:1 and then by c37076082034003d an get the sum the increase in errors, which in this example would be 3
Every thing I tried just throws various errors over the last 2 days of trying.
The search take a long time, and therefore I would prefer to be able to get it all on one string.
I can sort of get what I want by doing a search on just one error. If I try to search and pull the date for two or more errors I get syntax errors.
grep "St Lf" PL.210127* | sed -n 's/^.*(St Lf )/1/p'
St Lf Count changed by (11) (57 - 46) Pz Sq Ed Count changed by (2) (7 - 5) Ip Tp Wq Count changed by (52) (212 - 160)
I can pull the sum.
grep "St Lf" PL.210127* | sed -n 's/^.*(St Lf )/1/p' | awk '{print $6}' | grep -o '[0-9]+' | awk '{sum+=$1}END{print sum}'
I get the sum of the value in the ( )
If I can just pull the value in the ( ) per each count change "St Lf Count changed" "Pz Sq Ed Count changed" "Ip Tp Wq Count changed"
question from:
https://stackoverflow.com/questions/65945122/match-one-pattern-plus-2-other-patterns-return-data-in-from-both