[X-Unix] Any CLI multi-line regex find utilities out there?

Brian Medley bpm-list-osx-unix at 4321.tv
Wed Oct 27 13:14:07 PDT 2004


On Wed, Oct 27, 2004 at 02:04:49PM +0200, Jakob Peterh?nsel wrote:

> I though grep could do it, as BBEdit's version can, but got 
> disappointed. Grep can't find over multi-lines... 
> 
> So, is there any CLI solutions out there that can return a match on 
> text over multi lines??? 
> 
> I would like to do something like: 
> 
> echo 'my very long text from a email body' | myRegexCmd 'regex 
> expression' 
> 
> 
> Any help appreciated! 

$ cat test
a
b
c
1
2
3
perl
1
2
aa
$ perl -n -0777 -e 'print "$&\n" while m#([a-z]+\n)+#gms' test
a
b
c

perl

aa

$ perl -n -0777 -e 'print "$&\n" while m#(\d+\n)+#gms' test 
1
2
3

1
2

$ perl -n -0777 -e 'print "$&\n" while m#(1\n2)+#gms' test  
1
2
1
2
$

perldoc perlrun for info

-- 
~`^`'~=-._.-=~'`^`'~=-._.-=~'^'~=-., \|/  (___)  \|/ _,.-=~'`^`
                                      @~./'O o`\.~@
      "Knowledge is Power"           /__( \___/ )__\  *PPPFFBT!*
         -- Francis Bacon               `\__`U_/'
 _.-=~'``'~=-._.-=~'``'~=-._.-=~'`^`'~= <____|'  ^^`'~=-.,__,.-=
~'^`'~=-._.-=~'`^`'~=-._.-=~'^'~=-.,__,.-==--^'~=-.,__,.-=~'`^`


More information about the X-Unix mailing list