Reputation: 14571
Is it possible to use grep to high lite all of the text starting with:
mutablePath = CGPathCreateMutable();
and ending with:
CGPathAddPath(skinMutablePath, NULL, mutablePath);
Where there is an arbitary amount of text in between those two phrases?
NOTE: I have to use grep because I'm using BBEdit.
Upvotes: 3
Views: 2520
Reputation: 54572
You will need to use GNU grep
:
grep -oPz 'mutablePath = CGPathCreateMutable\(\);.*?(\n.*?)*.*?CGPathAddPath\(skinMutablePath, NULL, mutablePath\);' file
If you don't have GNU grep
, you could use pcregrep
to achieve the same thing:
pcregrep -M 'mutablePath = CGPathCreateMutable\(\);.*(\n|.)*CGPathAddPath\(skinMutablePath, NULL, mutablePath\);' file
Upvotes: 3
Reputation: 786051
You can use sed instead like this:
sed -n '/mutablePath = CGPathCreateMutable();/,/CGPathAddPath(skinMutablePath, NULL, mutablePath);/p' infile
EDIT:
Not sure if -P
flag of grep is supported in BBEdit. If it is then you can use this:
grep -oP 'mutablePath = CGPathCreateMutable();\X*CGPathAddPath(skinMutablePath, NULL, mutablePath);/' infile
As per grep man page:
-P, --perl-regexp Interpret PATTERN as a Perl regular expression.
Upvotes: 0
Reputation: 33928
If you want to print the lines between and including these you could use:
perl -ne '/start line/ .. /end line/ and print'
Upvotes: 0