Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #GFILE=/var/log/mail.log
- GFILE=mail.log
- #GFILE=test.log
- if [[ -z $1 ]] || [[ $4 ]]
- then
- echo 'You need to specify between 1 and 3 variables of input.'
- exit
- fi
- EMAIL="[A-Za-z0-9\.\$\_\-]*@[A-Za-z0-9\.\$\_\-]*"
- IPADD="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
- RED="\033[1;31m&\033[0m"
- GREEN="\033[1;92m&\033[0m"
- BLUE="\033[1;34m&\033[0m"
- PINK="\033[1;95m&\033[0m"
- CYAN="\033[1;96m&\033[0m"
- more=()
- more+=('gsub("'"$1"'", "'"$RED"'");')
- more+=('gsub("'"$EMAIL"'", "'"$GREEN"'");')
- more+=('gsub("'"$IPADD"'", "'"$BLUE"'");')
- if [[ $2 ]]
- then
- more+=('gsub("'"$2"'", "'"$CYAN"'");')
- fi
- if [[ $3 ]]
- then
- more+=('gsub("'"$3"'", "'"$PINK"'");')
- fi
- grep $1 $GFILE | gawk --re-interval '{ printf '%s\n' "${more[@]}"} print }'
Advertisement
Add Comment
Please, Sign In to add comment