You are here: RE: [PHP] Parsing a large file « PHP « IT news, forums, messages
RE: [PHP] Parsing a large file

Posted by "Richard Lynch" on 01/14/06 00:21

On Fri, January 13, 2006 8:37 am, Albert wrote:
> Wolf wrote:
>> I have large log files from a web server (about a gig in size) and
>> need
>> to parse each line looking for a string, and when encountered push
>> that
>> line to a new file. I was thinking I could have PHP read in the
>> whole
>> file, but thinking it could be a major pain since I have about 20
>> log
>> files to read through.
>>
>> Anyone have some suggestions?
>
> Is this on a Linux server?
>
> Why don’t you use grep?
>
> cat <filename> | grep <string> > <newfile>

If you DO use grep, don't cat the whole file out to grep it...

grep __filename__ > __newfile__

cat on a 1 GIG file is probably a bit wasteful, I suspect...

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация