I have the data exported from Sql query into a file temp.log
.
Below is the sample data. The entries after the header line are sorted on the first column.
Also, consider the nodes (36,54,69,76) as fixed list
<Name> <Status> <Node> <Requests>
AString1 Success 36 1
AString1 Success 54 4
AString1 Success 69 3
AString1 Success 76 4
BString2 Success 36 1
BString2 Success 54 2
BString2 Success 69 3
BString2 Success 76 1
CString3 Success 36 8
CString3 Success 54 7
CString3 Success 76 8
DString4 Success 36 8
DString4 Success 54 4
DString4 Success 69 12
DString4 Success 76 7
I need output as below
<Name> <Nodes> <Count of Requests>
Astring1 36 54 69 76 12
BString2 36 54 69 76 7
CString3 36 54 NA 76 23
DString4 36 54 69 76 31
Here the Last Column (<Count of Requests>
) indicates the Total Count of requests on each node of the Name.
NA
should be printed if a node didn't receive any requests.(Can see for CString3 row in o/p, it has one row missing for node value 69
, in that case it should be NA
, like CString3 36 54 NA 76 23
In success case DString4 - DString4 36 54 69 76 31
Can this be done with awk command?