
August 26th, 2003, 09:43 AM
|
|
Contributing User
|
|
Join Date: Aug 2003
Location: Jersey
Posts: 64
Time spent in forums: < 1 sec
Reputation Power: 6
|
|
|
Well, if it were me, I'd tail out the lines to a temp file, then zero out the original, and cat the temp contents back into the original, i.e.:
FILE1=/path/to/current/file
TEMPFILE=/tmp/newfile
tail -100 > $TEMPFILE
cat /dev/null > $FILE1
cat $TEMPFILE >> $FILE1
That should do it and keep the permissions set, since you're not deleting the file, just modifying it's contents. If you need any different number of lines, not 100, you can just substitute the number in the tail line above.
I'm sure there's another cleaner way to do this, but the above should be a workable hack.
-Gary
|