0

consider the following

[Settings]
Flags=17
InHouse=0
PrintMode=4
version=3.0
Background Color=16051165
AutoSaveMin=900000
DefaultTemplate=Untitled.ipt
Save template=1

I'm using grep to loop through thousands of ini files to look for the following:

version=3.0

AND

DefaultTemplate=[alphanumeric]

below does not return any results, what am I missing?

version=3.0[\s\S]*DefaultTemplate=[A-Za-z0-9]

Bhargav Rao
  • 45,811
  • 27
  • 120
  • 136
BelgoCanadian
  • 867
  • 1
  • 8
  • 29
  • possible duplicate of [How to find patterns across multiple lines using grep?](http://stackoverflow.com/questions/2686147/how-to-find-patterns-across-multiple-lines-using-grep) – Wrikken Dec 10 '14 at 22:52
  • As a regex it appears ok. Is it a grep question? You should use the layz quantifier version though `version=3.0[\s\S]*?DefaultTemplate=[A-Za-z0-9]` –  Dec 10 '14 at 23:06

1 Answers1

1

Try this:

grep -P '(DefaultTemplate=[\w\.]+|version=[\d\.]+)' *
Gilles Quenot
  • 154,891
  • 35
  • 213
  • 206