[SunHELP] Shell Script

Dale Ghent sunhelp at sunhelp.org
Mon Mar 26 13:18:51 CST 2001


On Mon, 26 Mar 2001, Balaji N wrote:

| Hi everyone
| 
| I have a directory which contains *.log files and txt files. I need a
| shell  script which  can clear all lines in *.log files and keeping some
| latest 100 lines . I can put the script as cron job, so that it can
| run in weekly basis. can anyone have?

#!/bin/sh

umask 022
cd /driectory

for i in *.log *.txt; do 

   tail -100 $i > /tmp/foo
   mv -f /tmp/foo $i; done

done


/dale




More information about the SunHELP mailing list