[Kc] RegExes
Emmanuel Mejias
emmanuel.mejias at gmail.com
Mon Mar 31 18:29:35 PDT 2008
hey guys, I'm trying to match two patterns, say */var/log/ *from
/etc/syslog.conf, using regexes? but I don't want to match every line with
log (Logging, log) which is what I'm getting. I tried just matching /var/,
but I was trying for two patterns. what would be the correct way?
code:
#!/usr/bin/perl -w
@input = `cat /etc/syslog.conf`;
foreach $line (@input) {
if ($line =~ */[varlog]/*){
print $line;
}
}
I want my output to look something like this....
*.info;mail.none;authpriv.none;cron.none /var/log/messages
authpriv.* /var/log/secure
mail.* -/var/log/maillog
cron.* /var/log/cron
uucp,news.crit /var/log/spooler
local7.* /var/log/boot.log
not like this....
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/kc/attachments/20080331/f3605db3/attachment.html
More information about the kc
mailing list