#!/bin/bash# *************************************************************# This function redirect the pipe input to STDERR.## @param stream# @return string#function STDERR () {
cat - 1>&2
}
# remove the directory /bubuif rm /bubu 2>/dev/null; thenecho "Bubu is gone."elseecho "Has anyone seen Bubu?" | STDERRfi
# run the bubu.sh and redirect you outputtux@earth:~$ ./bubu.sh >/tmp/bubu.log 2>/tmp/bubu.err
echoerr() { printf "\e[31;1m%s\e[0m\n" "$*" >&2; }
# if somehow \e is not working on your terminal, use \u001b instead# echoerr() { printf "\u001b[31;1m%s\u001b[0m\n" "$*" >&2; }
echoerr "This error message should be RED"