Search This Blog

Friday, May 25, 2018

Display grep output in color in Bash

Error in Red color.
Failed in Yellow color.
warning in Blue color.

#!/bin/bash

RED='\033[1;31m'
YELLOW='\033[1;33m'
CYAN='\033[1;36m'

export LOG_FILE=/home/log/process.log

echo -e "${RED}Display Error message in build log:$LOG_FILE"
grep error $LOG_FILE | grep --color=always -v libgpg-error0

echo -e "${YELLOW}Display Failed message in build log:$LOG_FILE"
grep Failed $LOG_FILE | grep --color=always -v libgpg-error0
grep failed $LOG_FILE | grep --color=always -v libgpg-error0

echo -e "${CYAN}Display warning message in build log:$LOG_FILE"
grep warning $LOG_FILE | grep --color=always -v libgpg-error0

No comments:

Post a Comment