giladh

MX Log Search

Jul 6th, 2011
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1. #!/bin/bash -e
  2.  
  3. echo -e "\nThis script searches the mail logs for particular patterns or strings\n"
  4. read -p "Please enter the patterns you would like me to search for (separated by a comma or space): " PATTERNS
  5.  
  6. SEARCHTERMS=$(echo $PATTERNS | sed -e 's/ /|/g' -e 's/,/|/g)
  7.  
  8. if [ -n "$PATTERNS" ]
  9.  then
  10.    zegrep -si "$SEARCHTERMS" /var/log/messages*
  11. else
  12.     echo you must enter at least one search term!    
  13. fi
  14.  
  15. exit
Advertisement
Add Comment
Please, Sign In to add comment