1827800 Members
2357 Online
109969 Solutions
New Discussion

perl special character

 
SOLVED
Go to solution
OFC_EDM
Respected Contributor

perl special character

I'm trying to find the line
#DISABLETIME=48 (or any 2 digit value)

and replace with

DISABLETIME=60 (note: now uncommented)

My command is
perl -pi.old -e 's/\b\\#DISABLETIME=\d\d\b/DISABLETIME=60/' filename

Where I've tried escaping the # character. Also tried various forms of quoting etc. but without success.

What's wrong with my command?

Cheers
The Devil is in the detail.
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: perl special character

Hi:

Make the boundry (\b) and optional match:

# perl -pi.old -e 's/\b?\#DISABLETIME=\d\d\b/DISABLETIME=60/' filename

Regards!

...JRF...
OFC_EDM
Respected Contributor

Re: perl special character

Not sure I understand why that works...but it does.

Thanks James

(who also provided the original code as a solution for me in a different thread!! :)
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: perl special character

Worked
The Devil is in the detail.