Link to home
Start Free TrialLog in
Avatar of saharey
saharey

asked on

Find Replace with perl -pi

I am doing find and replace like this

find /path/to/folder -name '*.*' -print0 | xargs -0 perl -pi -e "s/3\.1\.00/8\.4\.0\.${DATE}/g"

When I run the above script it works fine, but the problem is it is replacing a text "3.1.00.00" also, I am confused how come it is replacing a 4 octet string.

I am not finding a string with 4 digits only 3 digits is being asked to replace.

Say string is "3.1.00.00" than it gets replaced like this "3.1.0.2009012800.00"

Anyone with a quick help?
Avatar of ozo
ozo
Flag of United States of America image

Do you only want to replace 3\.1\.00 only when it is not followed by \. ?
if so, you can do
s/3\.1\.00(?!\.)/8\.4\.0\.${DATE}/g
Avatar of saharey
saharey

ASKER

it worked but the orginal string
"3.1.00" is now getting replaced like this "3..^@.2009012802"

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial