0

I need to grep a long text file for lines that contains multiple possible words and also end in "=1", and then replace the line with the same text except change the "=1" to "=0".

I'm using BBEdit.

So far I have this to find lines that contains the desired match that also ends with 1:

^(.*test|.*disabled|.*inactive|.*server).*(=1)

I'm unable to do the replacement successfully though.

Here are some example lines of text from the file:

OU>2020,OU>Disabled Accounts,DC>net,DC>example,DC>com=1
OU>Distribution Groups,DC>net,DC>example,DC>com=1
OU>Exchange Servers,DC>net,DC>example,DC>com=1
CN>Users,DC>net,DC>example,DC>com=1
OU>Test Servers,OU>Servers,OU>ABC,DC>net,DC>example,DC>com=1

As an example, the first line above would have its =1 changed to =0 like:

OU>2020,OU>Disabled Accounts,DC>net,DC>example,DC>com=0

Other matches would follow that pattern.

mindmischief
  • 271
  • 1
  • 12

1 Answers1

1

After playing around with it more, this seems to work:

Find:

(^.*(test|disable|inactive|server).*)(=1)$

Replace:

\1=0
mindmischief
  • 271
  • 1
  • 12