| Author |
Needs help for grouping data
|
Sam Saha
Ranch Hand
Joined: Jan 23, 2010
Posts: 89
|
|
I have a log file sitting in UNIX server which is a combination of ERROR and CRIT in a random order. I want to group all ERROR together and all CRIT together. And there are so many lines for each ERROR and CRIT. I just want to capture only main error description line from each ERROR and CRIT to reduce the file. I have to write unix script to handle this. I am very new to UNIX and before writing script I want to write an algorithm for that. I am wondering if someone can show me the algorithm for this.
The log file looks like this:
I want the output like this:
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
grep for lines that start with one of your keywords, then sort the result:
|
[Jess in Action][AskingGoodQuestions]
|
 |
Sam Saha
Ranch Hand
Joined: Jan 23, 2010
Posts: 89
|
|
|
I would appreciate if you could show the algorithm for that.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
|
Note sure what you mean by "algorithm" here. The egrep command filters out only those lines that start with ERROR ("^ERROR") or ("|") start with CRIT ("^CRIT").Those lines are then piped to the sort program, which will group lines starting with the same keywords together.
|
 |
 |
|
|
subject: Needs help for grouping data
|
|
|