Issue
I need help figuring out the syntax or what command to use to find an replace a specific number in a file. I need to replace the number 10 with 25 in a configuration file. I have tried the following:
sed 's/10/25/g' /etc/security/limits.conf
This changes other instances that contain 10 such as 1000 and 10000 to 2500 and 25000, I need to juct change the need to just change 10 to 25. Please help.
Thank you,
Joseph
Solution
The trick here is to limit the sed
substitution to the line you want to change. For limits.conf
you are best off matching the domain, type and item. So if you wanted to just change a limit for domain @student
, type hard
, item nproc
, you'd use something like
sed '/@student.*hard.*nproc/s/10/25/g' /etc/security/limits.conf
Answered By - Jon