OT: cat and tail

Scott Haneda talklists at newgeo.com
Sat Dec 19 18:14:35 PST 2009


On Dec 19, 2009, at 2:21 AM, Chris Janton wrote:

> On 2009-12-18 , at 21:02 , Scott Haneda wrote:
>>
>> I run a script that does this
>> tail -f -n0 /path/to/log.log >> /path/to/log/running_log
>> The problem is, the log.log grows, it will get chopped in half by  
>> the app at a point in size I define, I set mine pretty high.  I  
>> want to get those log lines in MySql, parsing 100MB files is not fun.
>
> what happens if you do the following while your 'tail' is running
>
> gsed -i '1,100000d' log.log
>
> assumes that there are 100,000 lines+ in log.log - assumes that you  
> have processed the first 100,000 lines too.
>
>  -i "edit the file in place
>  '1,100000d' delete lines 1 through 100,000

I think that does it.  I can get a line count of the log, and use that  
in gsed to truncate the file to what I need.  If more are added, it  
does not matter, I am using the line count I originally got, which is  
something less than what is in the log file to begin with.

Win!  Thanks.

* Any packagemaker masters out there?
-- 
Scott * If you contact me off list replace talklists@ with scott@ *



More information about the macports-users mailing list