# This set of cuts looks through the messages.1 file and returns a list of # unique message types: # cut -d " " -f 5 messages.1 | cut -d '[' -f 1 | sort -u # # Try just that line to see what it does. # # The most unkindest cut of all - well, maybe not but it is using Brutus force. # (OK, it's a bad Shakespeare pun. What other kind is there?) # # The -d option on the first cut says to use a space (" ") as the delimiter between fields # Then select the 5'th field which will be named, sshd[1234], ntpd[1234], etc. # # The second cut uses "[" as the delimiter and takes the first field. # For "named", the first (and only) field is "named" # For "sshd[1234]" the first field is "sshd" (and the second is "1234]" # Merge that line into the script in place of the hardcoded message types: for msg in `cut -d " " -f 5 messages.1 | cut -d '[' -f 1 | sort -u` do # A similar cut to look at the second field in the line - the day of the month for i in `cut -d " " -f 2 messages.1 | sort -u` do echo "There were `grep " $msg" messages.1 | grep "Dec $i" | cut -d ' ' -f 3 | sort -u | wc -l` $msg lines On Dec $i" done done # For double brownie points (on your own) get rid of the hardcoded Dec and make # this script truly generic (and useful)