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
I need to find and delete a file to enable printer driver installation
Public Folder Migration
Can not install new programs with out "AIM Install" Dialog Prompt
TV card problems
Partition XP Drive: Combine two partitions when temp install files are residing on C:
Printing directly from a webpage and printer settings.
Detecting Proxy Settings
Flash Expanding Menu
Cannot find manufacturer for Sony VAIO PCV-RZ22G TV tuner card in order to install on SUSE 10.3
How to implement OpenSSL on Apache? (via Apache2Triad installation on Windows 2000 Server)