Reputation: 141
I am looking to create a cronjob that will alert us if a certain directory has sent out a certain amount of emails from scanning a log file. The one liner I am using is:
awk '$3 ~ /^cwd/{print $3}' /var/log/exim_mainlog | sort | uniq -c | sed "s|^ *||g" | sort -nr | head --lines 5
before I get any further, I need to exclude some locations from the output, example:
50992 cwd=/var/spool/exim
21960 cwd=/home/USER1/public_html/wp-content/cache/object/000000/746
2717 cwd=/etc/csf
2063 cwd=/home/USER2
1072 cwd=/
I need to exclude:
1072 cwd=/
2717 cwd=/etc/csf
50992 cwd=/var/spool/exim
Would I need to append the output to a txt file then use SED or is there an easier method?
Upvotes: 0
Views: 90
Reputation: 295639
Pipe through grep -v
to exclude matches:
egrep -v ' cwd=(/$|/etc/csf|/var/spool/exim)'
Upvotes: 2