Shell – count the keyword

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

#!/bin/bash

# perhaps the field to be analyted is the 2nd field
log=/path/to/log;
keyword=”the keyword”;
cat $log | cut -f2 | grep $keyword | sort | uniq -c -i

[/codesyntax]

Posted in Linux | Tagged | Leave a comment