Unix Shell - Segment file with EGREP?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > February 2005 > Segment file with EGREP?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Segment file with EGREP?
david

2005-02-10, 5:58 pm

I have a text file with sections of the file divided by a string of
characters, i.e.

***********************************

How would I use egrep to segment the file for every 100th occurence of
the "***********************************" string?

Thank you in advance.

Ed Morton

2005-02-10, 5:58 pm



david wrote:
> I have a text file with sections of the file divided by a string of
> characters, i.e.
>
> ***********************************
>
> How would I use egrep to segment the file for every 100th occurence of
> the "***********************************" string?
>
> Thank you in advance.
>


awk could do this easily, e.g. (untested):

awk '/***********************************/{c++;if (c==100){fn++;c=0}}
{print > FILENAME "." fn}' fn=0 file

Do you really need to use egrep?

Ed.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com