I am writing a script to alter the few values in file sysctl.conf in /etc directory
If variable value is less than that then it should alter the value to below given value
For example:
sysctl.conf file contains the following lines (the terms in parentheses are my own comments and are not in the actual file):
kernel.shmall = 5194304 (more than 4194304 so it should leave it as it is)
kernel.shmmax = 2147483648 (it is equal to 2147483648 so it should leave it as it is)
kernel.msgmni = 124 (it is less than 1024 so it should alter the value to 1024)
expecting output is
kernel.shmall = 5194304
kernel.shmmax = 2147483648
kernel.msgmni = 1024
This is my script I am preparing to replace kernel.shmall if value is less than or equal to 4194303
script:
#!/bin/sh
echo `cat /etc/sysctl.conf|fgrep kernel.shmall` | while read kernel.shmall
if [ "kernel.shmall" -le 4194303 ]; then
kernel.shmall = 4194304
fi`