bleg: chopping a plain-text file
Oct. 18th, 2007 12:42 pmA question for systems people:
If a plain-text log-file gets too big to be openable by emacs (in my case 379MB), how can I search through it? Is it possible to chop such a file into several pieces?
grep works, but it doesn't let me see the context surrounding my hits.
UPDATE:
If a plain-text log-file gets too big to be openable by emacs (in my case 379MB), how can I search through it? Is it possible to chop such a file into several pieces?
grep works, but it doesn't let me see the context surrounding my hits.
UPDATE:
grep -An -Bn pattern file seems to find n lines before and after each hit. Still, not as good as a text editor...
(no subject)
Date: 2007-10-18 04:50 pm (UTC)(no subject)
Date: 2007-10-18 04:55 pm (UTC)(no subject)
Date: 2007-10-18 04:58 pm (UTC)head --lines=<half the number of lines returned by wc> >> <file_1.txt>
tail --lines=<remaining number of lines> >> <file_2.txt>
(no subject)
Date: 2007-10-18 05:05 pm (UTC)(no subject)
Date: 2007-10-18 05:17 pm (UTC)Is there a command similar to 'head' and 'tail', but where you can specify a range in the middle?
(no subject)
Date: 2007-10-18 05:39 pm (UTC)(no subject)
Date: 2007-10-18 05:39 pm (UTC)head --lines=<X> <file.txt> | tail --lines=<X> >> <file_middle.txt>
But you're starting to get into the realm where writing a quick perl script would probably be easier/more-functional. If my perl weren't super rusty, i'd offer to do it, but...it is and I'm crazy busy. :-)
(no subject)
Date: 2007-10-18 05:40 pm (UTC)(no subject)
Date: 2007-10-18 05:40 pm (UTC)dd if=oldfilename of=filepartN bs=1024 count=K skip=J
Will copy K kilobytes starting at kilobyte J from oldfilename into filepartN.
(no subject)
Date: 2007-10-18 06:09 pm (UTC)(no subject)
Date: 2007-10-18 06:45 pm (UTC)(no subject)
Date: 2007-10-18 06:52 pm (UTC)(no subject)
Date: 2007-10-18 07:05 pm (UTC)Now if we've learned anything from the sad tale of Endo the alien, we would realize that _ropes_ are the right datastructure for a text editor.... :-D
(no subject)
Date: 2007-10-18 07:10 pm (UTC)(no subject)
Date: 2007-10-18 07:11 pm (UTC)(no subject)
Date: 2007-10-18 07:12 pm (UTC)Not as fast as grep or anything like as featureful as emacs, but it doesn't choke on big files or long lines.
(no subject)
Date: 2007-10-18 07:15 pm (UTC)(no subject)
Date: 2007-10-18 07:29 pm (UTC)(no subject)
Date: 2007-10-18 07:33 pm (UTC)Some programs also have the ext2 file size limit built in so even if you're accessing files on filesystems without this limit they can't handle it. Apache, for example, refused to serve files bigger than 2GB until very recently (like, within the last year or so, if I remember correctly).
(no subject)
Date: 2007-10-18 07:33 pm (UTC)(no subject)
Date: 2007-10-18 08:03 pm (UTC)(no subject)
Date: 2007-10-18 08:18 pm (UTC)(no subject)
Date: 2007-10-18 08:38 pm (UTC)(no subject)
Date: 2007-10-18 08:42 pm (UTC)