hey...
I am in need of some help with finding words in my file on particular line, and if the word exists, it will skip appending the phrase and if the word does not exist, it will add it.
For example, here is the kernel line of grub.conf:
kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/ rhgb quiet
if this line doesn't have "audit=1", I need to add it. I can do this (by searching for vmlinuz-2.6)
Code:
sed -i '/vmlinuz-2.6/ s|$| audit=1|' /boot/grub/grub.conf
But some of my grub.conf files have multiple kernel lines with vmlinuz-2.6 and some already have the "audit=1" appended to them. So, I need to be able to search for those lines that do not have "audit=1" and append it, but ignore the lines that already have it.
Any ideas?