atom_jelly
asked on
if string is there then do nothing
I am trying to create an if statement that searches for the string and if its there don't do anything my script is still writing into the file I want it to not write if the string is there and if its not there then write the string into the file this is what I have.
if grep -q "string" /etc/syslog.conf
then
sed -i -e '/^authpriv.info/ a\
authpriv.none\t\t\t\t\t\t\ t/var/log/ secure' /etc/syslog.conf
else
if grep -q "string" /etc/syslog.conf
then
echo "authprive.none exists"
fi
fi
if grep -q "string" /etc/syslog.conf
then
sed -i -e '/^authpriv.info/ a\
authpriv.none\t\t\t\t\t\t\
else
if grep -q "string" /etc/syslog.conf
then
echo "authprive.none exists"
fi
fi
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER