I try to match a a group twice in multiline.
grep -Pz 'Source: (?<group>.*/).*\n.*\n.*\n.*\k<group>|$'
it work except one major problem - it doesn't,
\k<group> search for
.*/ and not for the same characters that the first occurrence of group matched, which is normal considering that backreferencing is dynamic.
Is it possible to get «static» backreference, meaning that if
(?<test>\d\d) match 45 , the next call to group test will always look for 45?
I'm not really good at explaining technical terms in english so feel free to yell at me or simply tell me to be more specific.
(I use perl grep here but if you have a solution who doesn't use it, go ahead)
To answer the comment below: 1: I have a script that bulk move a lot of images files depending of ex if data. It works flawlessly but I want to test if in some cases the source Dir is the same as the output Dir.
A sample of a move:
[1/1] (TEST - no files are being moved/copied)
Date/Time: 2013-06-11 16:37:23
Corresponding Tags: Composite:GPSDateTime
Destination (move): ./2013/06-Jun/20130611_163723.IMG_20130611_183722.jpg
Here the input and output are not the same so I want the script to not detect anything but if
Destination (move): /disk/media/Camera/20130611_163723.IMG_20130611_183722.jpg
I want to highlight the four lines. The purpose is not to retrieve the data for anything else but just to visually identify quickly the detected files.
With the regexp up there it always highlight since the second occurrence of the group is dynamic (for grep it doesn't matter that the both are not identical)