Question

So I have this really long file in which there are lines that are built like this:

`somecode [ somecode > somecode ] somecode > somecode > somecode` 

I have to search for a string of atleast 9 + or - characters between the brackets and the same thing that was matched between those brackets have to be found between the two '>' next to the brackets... So far I came up with this;

`cat file | egrep -n '*\[.*([-+]{9,}).*\].*(>).*\1.*(>).*' > out.txt`
Was it helpful?

Solution

i guess from your regex,this is what you wanted to do

\[.*?([+-]{9,}).*?\].*?>.*?\1.*?>

if you want to get the full line use this

^.*?\[.*?([+-]{9,}).*?\].*?>.*?\1.*?>.*?$
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top