Scroll to navigation

CCECHO(1) Conditional Color Echo CCECHO(1)

NAME

ccecho - ccecho (conditional color echo) lets you use colored output for STDOUT while using regular output for log files, pipes and scripts

SYNOPSIS

ccecho LEVEL MESSAGE

DESCRIPTION

Prints a colored message string to STDOUT or STDERR using bash color codes. The color and the output channel depend on the LEVEL keyword. When the SHELL environment variable COLOR is set to either "0" or "no" no color output is generated.

The main purpose of this script is to provide an easy method to generate colored output when the output should go to STDOUT, and regular output (using echo -e) for log files, pipes and scripts (by exporting COLOR=0).

PARAMETERS

ccecho takes two parameters, both are mandatory:

LEVEL

Determines which color is used. Must be used as the first parameter. Is ignored, when the ebvironment variable COLOR is set to "0" or "no".

error   ->  bold red, STDERR
info    ->  purple, STDOUT
normal  ->  no color, STDOUT
result  ->  green, STDOUT
warn    ->  red, STDERR

MESSAGE

The message to be printed. Needs to be quoted using double quotes. You may use sequences supported by echo (1) such as \n to insert a newline and \t to insert a tab.

ENVIRONMENT

COLOR

When set to "0" or "no", ccecho will act as plain echo -e doing no colored output.

SEE ALSO

echo(1)

AUTHOR

Frank Sundermeyer <fsundermeyer@opensuse.org>

Developer
01/10/2020 1.0