On Sat, 21 Sep 2002 23:43:23 +0800 begin "M.W. Chang" <[EMAIL PROTECTED]> spewed forth:
> I could figure this one out. but how to list all possible combinations > of DPT=9999 in a text file? There should be an existing shell util that > will do something like this: > > select distinct DPT=* from textfile grep DPT= /var/log/messages [ | grep `date` ] | sort -k 8 | wc (assuming field 8 is the DPT= field, this will tell you how many DPT= you have) Now, if you only need certain fields, you can grab those using cut (to cut out only the fields you want), use awk to move the fields around (putting DPT= first), then use uniq (which when run with certain switches will give you a count of each uniq line, such as if you only cut out DPT= , you can get a count of each uniq DPT= value Is the above what you need to do? > > then I need to direct each combination into a file and apply wc on it to > produce a distribution > > > grep DPT=9999 /var/log/messages | wc example: zcat messages.1.gz | cut -f6 -d\ - | sort | uniq -c yields the following partial output: 1 snort 1 sr0: 1 sr1: 3 ttyS00 21 usb-uhci.c: 13 usb.c: 1 usbkbd.c: 15 vesafb: 1 vga16fb: So I have 21 instances of usb-uhci.c, 13 of usb.c, 15 of vesafb, 3 of ttyS00, and one of the rest (had I sorted this in reverse order (sort -r), you'd have seen the most prominent on top, etc. That help? David A. Bandel -- Focus on the dream, not the competition. -- Nemesis Racing Team motto _______________________________________________ Linux-users mailing list [EMAIL PROTECTED] Unsubscribe/Suspend/Etc -> http://www.linux-sxs.org/mailman/listinfo/linux-users