Kevin Pfeiffer <[EMAIL PROTECTED]> writes: > Robin Norwood writes: > > Samuel Brown <[EMAIL PROTECTED]> writes: > > > Hi ya, > > > > > > I'm teaching myself Perl and I have a log file around 1GB that I need > > > to sort by month | date | time | byte size. So far I have parse the log > > > for "bytes" since this is all that I need but I can't get it to sort > > > like I want. > [...] > > First, I hope I'm understanding you correctly - you have this file, in > > 'some order', which you need to sort by month, then by date, then > > time, then bytce size. If that's not right, please enlighten me. If > > I understand your problem, however, read on - > [...] > > Bad news: it's not going to work for you, because it's going to curl > > up and die when it tries to load a GB file into RAM, copy it, sort it, > > and spit out another copy. > [...] > > What other approaches might be possible? The first that comes to mind for me > is don't wait until you have a 1GB log file; if you do this on a daily > basis.... My second thought is can you open the file, read one line at a > time and then write these lines to one of several smaller files based on > the first sort criteria; thereafter then finish sorting the sub-files?
Both of those would work. Assuming he's already got 1GB of data, it's too late for the first. The second would work, but it would at least double the disk space used during the copy. What I can't figure out is, if this log file is generated by a program which inserts a line at the end every time and action occurs, it should already be ordered by month/day/time. So I'm not sure that the original poster gave us enough data. -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]