same script:
1- i am using grep to find a string called: tinker panic 0 in a file /etc/ntp.conf
if the string is not there, i want to add the strings in /etc/ntp.conf file in the first line of the file. if not do nothing or exit.
2- also i want to add # in front of the following lines in /etc/ntp.conf only if # is not there.
#server 127.127.1.0 # local clock
#fudge 127.127.1.0 stratum 10
Here what i have so far, but not working properly:
#!/bin/bash
#
const='tinker panic 0';
if [ -e /etc/ntp.conf ] ; then
found = 'grep "$const" /etc/ntp.conf' >/dev/null 2>&1
if [ "$found" -eq 0 ] ; then
echo "not found" ;
sed -i.bak '1 i\tinker panic 0' /etc/ntp.conf
fi
fi
Thank you very much!