#! /bin/env perl # feed a patchfile into STDIN # this will grep through the patch, and print out the matching patched files my $expr = shift; my $curFile = ""; my $printedFile = 0; my $lineNo = -10000; while (<>) { $lineNo++; if (m|^Index: ([\w\d\./]+)|o) { $curFile = $1; $printedFile = 0; $lineNo = -10000; next; } if (/^@@ -([\d]+)/o) { $lineNo = $1; next; } if (/$expr/o) { if (!$printedFile) { $printedFile = 1; print "$curFile\n"; } print " line $lineNo\n"; } }