Link to home
Start Free TrialLog in
Avatar of Hiro 714
Hiro 714

asked on

regular expression

#1 works fine, but #2 does not work. would you advise?
1. does work
sed -e 's/pinCode=[0-9][0-9][0-9][0-9][0-9][0-9]/pinCode=#######/g'

Open in new window

2. doesn't work
sed -e 's/pinCode=\d{6}/pinCode=#######/g'

Open in new window



Avatar of arnold
arnold
Flag of United States of America image

not all regex patterns work in sed
try \d+ instead of \d{6}
not sure \d{6} 6 digit works in all versions of sed or perl for that matter.
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
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
SOLUTION
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
Avatar of Bill Prew
Bill Prew

This should also work:

sed -e 's/pinCode=[[:digit:]]\{6\}/pinCode=#######/g'

Open in new window


»bp
if this is a syslog/rsyslog log retention you can set it up to be masked from the get go within the syslog/rsyslog process .