LouisDK

Untitled

Jun 29th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.77 KB | None | 0 0
  1. #!/bin/bash
  2. #GFILE=/var/log/mail.log
  3. GFILE=mail.log
  4. #GFILE=test.log
  5. if [[ -z $1 ]] || [[ $4 ]]
  6. then
  7.         echo 'You need to specify between 1 and 3 variables of input.'
  8.         exit
  9. fi
  10.  
  11. EMAIL="[A-Za-z0-9\.\$\_\-]*@[A-Za-z0-9\.\$\_\-]*"
  12. IPADD="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
  13. RED="\033[1;31m&\033[0m"
  14. GREEN="\033[1;92m&\033[0m"
  15. BLUE="\033[1;34m&\033[0m"
  16. PINK="\033[1;95m&\033[0m"
  17. CYAN="\033[1;96m&\033[0m"
  18. more=()
  19.  
  20. more+=('gsub("'"$1"'", "'"$RED"'");')
  21. more+=('gsub("'"$EMAIL"'", "'"$GREEN"'");')
  22. more+=('gsub("'"$IPADD"'", "'"$BLUE"'");')
  23.  
  24. if [[ $2 ]]
  25. then
  26. more+=('gsub("'"$2"'", "'"$CYAN"'");')
  27. fi
  28.  
  29. if [[ $3 ]]
  30. then
  31. more+=('gsub("'"$3"'", "'"$PINK"'");')
  32. fi
  33.  
  34. grep $1 $GFILE | gawk --re-interval '{ printf '%s\n' "${more[@]}"} print }'
Advertisement
Add Comment
Please, Sign In to add comment