Skip to main content
added 3 characters in body
Source Link
user14755
user14755

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m"; next;}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m"; next;}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m";  next;}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m";    next;}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m";   next;}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m";    next;}
     { print; }
'

With Bash uses, you can use shopt -s nocasematch for case insensitive pattern matching. eg.

mystring="AbCdEfG"
shopt -s nocasematch
if [[ ${mystring} == abcdefg ]] ; then
     echo "is a match!!"
fi

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m"; next;}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m"; next;}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m";  next;}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m";    next;}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m";   next;}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m";    next;}
     { print; }
'

Bash uses shopt -s nocasematch for case insensitive pattern matching. eg.

mystring="AbCdEfG"
shopt -s nocasematch
if [[ ${mystring} == abcdefg ]] ; then
     echo "is a match!!"
fi

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m"; next;}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m"; next;}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m";  next;}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m";    next;}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m";   next;}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m";    next;}
     { print; }
'

With Bash, you can use shopt -s nocasematch for case insensitive pattern matching. eg.

mystring="AbCdEfG"
shopt -s nocasematch
if [[ ${mystring} == abcdefg ]] ; then
     echo "is a match!!"
fi
updated to include catch-all as requested.
Source Link
user14755
user14755

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m""\033[39m"; next;}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m""\033[39m"; next;}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m""\033[39m";  next;}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m""\033[39m";    next;}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m""\033[39m";   next;}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m""\033[39m";    next;}
     { print; }
'

Bash uses shopt -s nocasematch for case insensitive pattern matching. eg.

mystring="AbCdEfG"
shopt -s nocasematch
if [[ ${mystring} == abcdefg ]] ; then
     echo "is a match!!"
fi

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m"}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m"}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m"}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m"}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m"}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m"}
'

Bash uses shopt -s nocasematch for case insensitive pattern matching. eg.

mystring="AbCdEfG"
shopt -s nocasematch
if [[ ${mystring} == abcdefg ]] ; then
     echo "is a match!!"
fi

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m"; next;}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m"; next;}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m";  next;}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m";    next;}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m";   next;}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m";    next;}
     { print; }
'

Bash uses shopt -s nocasematch for case insensitive pattern matching. eg.

mystring="AbCdEfG"
shopt -s nocasematch
if [[ ${mystring} == abcdefg ]] ; then
     echo "is a match!!"
fi
added 222 characters in body
Source Link
user14755
user14755

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m"}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m"}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m"}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m"}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m"}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m"}
'

Bash uses shopt -s nocasematch for case insensitive pattern matching. eg.

mystring="AbCdEfG"
shopt -s nocasematch
if [[ ${mystring} == abcdefg ]] ; then
     echo "is a match!!"
fi

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m"}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m"}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m"}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m"}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m"}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m"}
'

Awk has a function called 'tolower':

cat $logfile | awk '
     tolower($0) ~ /install/ {print "\033[32m" $0 "\033[39m"}
     tolower($0) ~ /success/ {print "\033[32m" $0 "\033[39m"}
     tolower($0) ~ /status/ {print "\033[33m" $0 "\033[39m"}
     tolower($0) ~ /info/ {print "\033[33m" $0 "\033[39m"}
     tolower($0) ~ /error/ {print "\033[31m" $0 "\033[39m"}
     tolower($0) ~ /fail/ {print "\033[31m" $0 "\033[39m"}
'

Bash uses shopt -s nocasematch for case insensitive pattern matching. eg.

mystring="AbCdEfG"
shopt -s nocasematch
if [[ ${mystring} == abcdefg ]] ; then
     echo "is a match!!"
fi
Source Link
user14755
user14755
Loading