On Tue, 7 Sep 2010, Swamisai, Ragavendar wrote:

> STRING
> 
> #ABC_XYZ foo.c(999) @ 19990 ns: foobar [foo] DATA packet mismatch..... Data 
> on wire is 
> 0000000000000000000000000000063b0000000000000000000000000000063b0000000000000000000000000000063b0000000000000000000000000000063b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
> 
> I want to print out just the line
> 
> #ABC_XYZ foo.c(999) @ 19990 ns: foobar [foo] DATA packet mismatch.....
> 
> I am able to do this if I do the below
> 
> % pcregrep -o -e "#\s+ABC_XYZ.*\.\.\.\." file.txt
> #ABC_XYZ foo.c(999) @ 19990 ns: foobar [foo] DATA packet mismatch.....
> 
> But need a way to do the above without using '-o' option

Well, you can't do that by anything you try inside the regex, because 
pcregrep either prints the whole line or the part that matched if you 
set the -o option. If you can't use the -o option, you will always get 
the whole line.

How about piping STDOUT to another instance of pcregrep (or some other 
program) to chop off the text after the ....   ? Or do that before 
passing the data to pcregrep?

Philip

-- 
Philip Hazel

-- 
## List details at http://lists.exim.org/mailman/listinfo/pcre-dev 

Reply via email to