Forum Moderators: bakedjake
Best explained by example I guess. Here's the kind of combo I'm using:-
tail -f /var/log/mylog.log¦grep "jedi"¦ awk '{ print $13 $9 $10 }'
Everytime Jedi appears in a line, I get that line output. But I only need each unique line once.
Currently I'm getting this for example:-
jedi keyphrase1 keyphrase2
jedi keyphrase1 keyphrase2
jedi keyphrase1 keyphrase2
jedi keyphrase1 keyphrase2
jedi keyphrase1 keyphrase2
jedi keyphrase1 keyphrase2
jedi keyphrase3 keyphrase4
jedi keyphrase3 keyphrase4
jedi keyphrase3 keyphrase4
jedi keyphrase3 keyphrase4
Repetitive. What I would like that transformed to is:-
jedi keyphrase1 keyphrase2
jedi keyphrase3 keyphrase4
All duplicates removed.
I can't grep on the keyphrases as I don't know what they are in advance. All I know in advance is that "jedi" will appear in the lines I'm interested in. Whilst that same line is likely to appear in the log again multiple times, I only need to know that it happened once.
Hope that makes sense. Is there something I can do with AWK or GREP or some other app to do this?
Thanks!
TJ