script to constantly read the last 500 new logs in a log file

Hello,

I would like to write a bash script that would monitor a log file for a certain number of logs, let's say 500 logs and when it reaches that number to write the last log to another file. For example, I want to watch the /var/adm/messages and everytime, there is 500 new logs that are generated in this file to write the last log into a new file lik /var/tmp/tmp1.log. So, if the logs keep popping up in the /var/adm/message, for every 500 of them there will one instance in /var/tmp/tmp1.log. But, it has to monitor for new logs. Let's say the script already read 500 logs, the count has to be for new logs occurence all the time. It should not consider previous logs that could have been in the /var/adm/messages before that it might have already read. Please give me some ideas.

Thank you,

Great! But it seems you forgot to include what you did already.

Please try to format your posts in a more readable way. Such monologue-style paragraphs are difficult to read.