On Feb 28, 10:56 am, "Xicheng Jia" <xich... gmail.com> wrote:
> On Feb 28, 3:09 am, "Todd Hlavacek"
<handsha... gmail.com> wrote:
>
> > Hello all,
>
> > I'm trying to figure out a way to write a Regex
statement (for each
> > file) where it stops after the first occurrence is
found/matched.
>
> > I have tons of files having multiple words having
a specific word
> > pattern. I need to just locate the first position
of that pattern in
> > each file before regex stops searching for THAT
file and moves on to
> > the next file.
>
> Hi, Todd:
>
> you need to tell us which tool you want to use to
handle your problem.
>
> >From my experience, GNU 'awk' has the easiest way:
>
> awk '/pattern/{print FILENAME, FNR; nextfile}' file*
>
> This prints the filename followed by the line_number of
the first
> match..
Another way with Perl:
perl -lne 'print "$ARGV $." and close ARGV
if/pattern/' file*
Regards,
Xicheng
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|