As part of my day job, supporting an old legacy PC app, I've just been handed a log file that's....er....11 GB in size. Actually "just been handed" is a bit of a lie - getting a copy of the file was entertaining (20 minutes of trying to connect my XP laptop to the customer LAN and no joy...20 seconds to get the iBook connected when their IT admin. finally allowed me :-)). It took 11 hours for Stuffit on my old B&W to get the file down to 350MB for archiving.
So...before I write some code to split this file up, I was wondering if there are any text editors for OSX (or earlier) that don't try and read all the file in before viewing? Something that loads the file in chunks perhaps?
Neil
I don't know exactly what you want to do, but the Unix text utilities are made for this kind of thing. I'm not sure these commands can handle files of such gargantuan size, but I think the chances are good. These are shell commands you should check out:
more -- Displays text file or files one screenful at a time. Typing a string finds the next instance of that string. If you just need to read the file, this may be enough.
head -- sends the first part of a file to stdout (could be screen or file)
head -25 bigfile.txt > beginning.txt
would create a new file with the first 25 lines of "bigfile.txt"tail -- sends the last part of a file to stdout head -500 bigfile.txt | tail -10 would display the last 10 lines of the first 500 lines of "bigfile.txt"
grep -- "get regular expression and print" search for a pattern, show results
sed -- the stream editor searches for patterns, excecutes fairly complex operations (including making changes) when found.
It's realatively easy with sed (and probably grep) to search for a pattern and display the next 'n' lines. With sed you can search for a pattern and display it in context of lines before and after the pattern:
Here is a shell script that uses sed to display the context of a pattern in a file:
: /bin/sh
# csed -- context search with sed
# author: Reinhard Foessmeier, Munich FRG
# from UNIXWorld 10/89 -- drd
if test "$#" -ne 2
then
echo "usage: $0 pattern filename"
exit 1
fi
#
sed -n -e "/$1/{=;x;p;x;p;n;p;}" -e h $2
All the work is done by the line at the end. $1 and $2 are the first and second arguments to the command script, respectively.
If you need to edit, the Unix editor "vi" is a screen editor with good ways to move around in a file and change things. Not the easiest program to use, but very convenient for some things.
If you want/need to stay in the GUI, I would try Text Wrangler / BBEdit.
Good luck, and let me know how it works out.
Dan
-- G-List is sponsored by <http://lowendmac.com/> and...
Small Dog Electronics http://www.smalldog.com | Refurbished Drives | -- We have Apple Refurbished Monitors in stock! | & CDRWs on Sale! |
Support Low End Mac <http://lowendmac.com/lists/support.html>
G-List list info: <http://lowendmac.com/lists/g-list.shtml> --> AOL users, remove "mailto:" Send list messages to: <mailto:[email protected]> To unsubscribe, email: <mailto:[EMAIL PROTECTED]> For digest mode, email: <mailto:[EMAIL PROTECTED]> Subscription questions: <mailto:[EMAIL PROTECTED]> Archive: <http://www.mail-archive.com/g-list%40mail.maclaunch.com/>
iPod Accessories for Less at 1-800-iPOD.COM Fast Delivery, Low Price, Good Deal www.1800ipod.com
