Link to home
Start Free TrialLog in
Avatar of Troush2009
Troush2009Flag for United States of America

asked on

How to use sed to replace a pattern out of a file?

How to use sed to replace a pattern out of a file?

Below is the line in rsyslog.conf that I am trying to replace.
*.info;mail.none;authpriv.none;cron.none                /var/log/messages

Want to replace it with this line:
*.*;mail.none;authpriv.none;cron.none,local1.none,local2.none,local3.none,local4.none,local5.none,local6.none /var/log/messages

try to use sed but can not get it to work correctly. Need some help on the best way to replace this line.
Avatar of gheist
gheist
Flag of Belgium image

how do you use sed? like sed -i ?
Avatar of wilcoxon
What exactly do you mean by "can not get it to work correctly"?
Avatar of Troush2009

ASKER

Below is what I try but could not get it to work.

sed -i 's^/\(.*\).*info;mail.none;authpriv.none;cron.none                /var/log/messages.*/\1*.*,mail.none,authpriv.none,cron.none,local1.none,local2.none,local3.none,local4.none,local5.none,local6.none /var/log/messages/' /etc/rsyslog.conf
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks