perl find a pattern between two patterns inside bash
I am looking for a regular expression using perl in a bash file (*.sh). I
need to find a dynamic pattern between two pattern.
For example:
some data
..
..
..
Pattern1
.. data
Dynamic_Pattern
...data
Pattern2
..
..
data
..
..
Pattern1
..data
Pattern2
the output will be:
Pattern1
.. data
dynamic pattern
...data
Pattern2
I found this code on the web:
perl -n0e 'while (/Pattern1.*?((?=Pattern2)|(?=$))/sg) {$x=$&;print $x if
$x=~/$Dynamic_Pattern/}' file
the problem is that it does not work if the Dynamic_Pattern id dynamic,
only if it static
No comments:
Post a Comment