modify content in a file using shell script
Hi,
I would like to add "-r" option into /etc/sysconfig/syslog file using bash shell script. How can I go about doing that? First I would like to check that file exists first before proceeding, 'cuz I want the script to be portable with other linux flavor. TIA. |
can you show us a line in /etc/sysconfig/syslog that you want "-r" to add to?
|
There are only 2 lines in my /etc/sysconfig/syslog file that aren't commented out.
To check if a file exists, try something like (in Bash): Code:
file='/etc/sysconfig/syslog'; To append "-r" to a specific line, you can use sed or awk. Or source the syslog file in Bash to get the variables $SYSLOGD_OPTIONS directly, modify them and then write them back into the file, like so: Code:
source /etc/sysconfig/syslog |
All times are GMT -5. The time now is 12:14 PM. |