manastria
10/29/2018 - 10:41 PM

Display content of multiples files

Display content of multiples files

#!/bin/bash

LogPath=/tmp
LogFileStdOUT=out
LogFileStdERR=err

if [ -t 1 ]; then                                                               ## if stdout is a terminal then COLORS
ColBLACK="\e[1;30m"                                                             ##
ColRED="\e[1;31m"                                                               ##
ColGREEN="\e[1;32m"                                                             ##
ColYELLOW="\e[1;33m"                                                            ##
ColBLUE="\e[1;34m"                                                              ##
ColMAGENTA="\e[1;35m"                                                           ##
ColCYAN="\e[1;36m"                                                              ##
ColLiGRAY="\e[1;37m"                                                            ##
ColDkGRAY="\e[1;90m"                                                            ##
ColLiRED="\e[1;91m"                                                             ##
ColLiGREEN="\e[1;92m"                                                           ##
ColLiYELLOW="\e[1;93m"                                                          ##
ColLiBLUE="\e[1;94m"                                                            ##
ColLiMAGENTA="\e[1;95m"                                                         ##
ColLiCYAN="\e[1;96m"                                                            ##
ColWHITE="\e[1;97m"                                                             ##
# -----------------------------------------                                     ##
ColRESET="\e[0m"                                                                ##
CommentColor="$ColLiGRAY"                                                       ## Color of comments in LIGHT GRAY
NoticeColor="$ColGREEN"                                                         ## Color of important notices in GREEN
TitleColor="$ColYELLOW"                                                         ## Color of Titles and Greetings in YELLOW
WarningColor="$ColRED"                                                          ## Color of Warning or ERRORs in RED
fi                                                                              ##

# StdOUT and StdERR LOG
if false
then
    exec > >( tee >( sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> $LogPath/$LogFileStdOUT ) )
    exec 2> >(tee -a $LogPath/$LogFileStdERR >&2)
fi

for filename; do
    echo -e "${ColLiGREEN}${filename}${ColRESET}"
    cat "$filename"
    echo
done