Issue
I have to replace the numeric values contained into a rhel configuration file through a bash script:
auth required pam_tally2.so onerr=fail deny=5 even_deny_root unlock_time=600 root_unlock_time=600
As long as these values are not the same, I'm unable to match a pattern. How can I find and replace (for example) unlock_time=600 with unlock_time=1000?
Solution
Using sed
$ sed 's/\(\<unlock_time=\)[^ ]*/\11000/' input_file
auth required pam_tally2.so onerr=fail deny=5 even_deny_root unlock_time=1000 root_unlock_time=600
Answered By - HatLess Answer Checked By - Mildred Charles (WPSolving Admin)