I'm trying to split a file based on context of certain lines, to transform it from this:
<random stuff>KEYWORD<random stuff> more lines section 1 <random stuff>KEYWORD<random stuff> more lines section 2 <random stuff>KEYWORD<random stuff> more lines section 3
to this:
FILE 1 <random stuff>KEYWORD<random stuff> more lines section 1 FILE 2 <random stuff>KEYWORD<random stuff> more lines section 2 FILE 3 <random stuff>KEYWORD<random stuff> more lines section 3
Basically, split a big file so any line that has the KEYWORD in it (anywhere in the line) is the first line of a new file. I want to number those files 1.txt, 2.txt, 3.txt, etc.
Since I'm going to be working with potentially 500+ files after the split, I can't use csplit, and that's the only unix utility I know that can do anything like this. Does anyone know of a possible 1 or 2 liner (or failing that, a short script) that can also do this? I'd appreciate any help.
Thanks,
Zel2008

New Topic/Question
Reply




MultiQuote




|