shell script that reads a file
I am totally new to shell scripting.
I need a korn shell script that will monitor a log file (shown below). It should scan the log file for distinct ip addresses. When the log file is deleted or a new file is created, the shell script should detect that.
For example, if at 11:00 pm the shell script detects 20 distinct ip addresses, and if at 11:10 the log file is deleted and a new one is created, then when we execute the script at 11:15, the shell script should return all the ip addresses (20 + the ip addresses from new file).
Therefore, the shell script should finally give the number of current ip addresses (distinct) at the end. To make things more clear, this script is used to track the number of current users using a server.
A snippet of log file is as shown below. 333.333.333.333 is the ip address. ip addresses are always preceded by the word AAD@.
10:54:11 [crelay_child-106762-0]: Reading local IPC message...
10:54:11 [crelay_child-106762-0]: Writing 220 bytes : LOGIN_MSG_RSP[-726510107](1)
10:54:12 [crelay_child-106762-0]: Scheduled send message to client on sfd 5
Sorry if this is a tough question. Your help will be greatly appreciated.
Thanks a lot in anticipation!!!
July 20th, 2003, 05:52 PM
Just wondering if you have considered doing this in PERL - it's quite a lot more flexible than ksh for this sort of thing. I'd definitely use PERL for parsing and matching -type tasks like this.
just a thought.
This is me: http://chris.uk.com