Microsoft
Software
Hardware
Network
Question : How can I grep, parse lines, and return count by certain fields?
-need a one liner that greps a file for all entries with 'FAIL'
-then it will parse through the lines and return a count for each unique name in field 'd' (note that fields are not always in the same order)
-if field d does not exist, count by field 'g'
Example:
XXXXXXXXXXXXXXXXXXXXXX$a=1
234:d=fred
:y=alphazX
XXXXXXXXXX
mFAIL
XXXXXXXXXXXXXXXXXXXXXX$d=f
red:a=4321
:y=bravozX
XXXXXXXXXX
mFAIL
XXXXXXXXXXXXXXXXXXXXXX$a=1
234:g=jack
son:y=char
liezXXXXXX
XXXXXmFAIL
XXXXXXXXXXXXXXXXXXXXXX$y=d
elta:a=135
7:d=bobbyz
XXXXXXXXXX
XmFAIL
--------------------------
------
If you were to run the one-liner on the above lines, the output should be:
fred 2
jackson 1
bobby 1
-If need be, it is ok to call perl for this execution
Answer : How can I grep, parse lines, and return count by certain fields?
zgrep FAIL file | perl -ne '(/\bd=(\w+)/||/\bg=(\w+)/
) && $c{$1}++;END{print"$_ $c{$_}\n" for keys %c}'
Random Solutions
Exchange 2003 Front-End/Back-End Info
RDP tru Cisco site to site VPN + microsoft vpn connection
copy Outlook 2007 Master category list to another computer
Premiere 1.5 >> FLV possible?
Query For Unique Values From the Same Table and Different Columns
Need XP audio driver for hp pavilion a6400
Search Engine Optimization required for travel website
HP t5720 thin client boots to user automatically used to boot to admin. How do I change it back.
"OPen With" Problem
Fedora Installation