cat works better when displaying color ASCII art, which can be important to consider when reviewing logged terminal output:
#!/bin/bash # log all terminal output exec &> >(tee -a log.txt) # ANSII color codes color_blue=$(tput setaf 4) color_reset=$(tput sgr0) bold=$(tput bold) # display banner printf '%s' "${color_blue}${bold}" cat <<'EOF' ::::::::: :::::::::: ::::::::: ::: :::::::: ::: ::: :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +#+ +:+ +#++:++# +#++:++#+ +#+ +#+ +:+ +#++: +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ #+# #+# #+# #+# #+# #+# #+# #+# ######### ########## ### ########## ######## ### EOF printf '%s' "${color_reset}"
Displays log with full color:
cat log.txt
Color is glitched after first line:
less log.txt less -r log.txt
less will also mangle the display terribly while paging back-and-forth if you've got ANSII control characters in the file, which can occur when logging interactive scripts which use techniques like this.
lessandcatsolve different problems and they are each better than the other in their own problem domaincatto pipe it's output intolessafterwards.catto print very short files to the console, the files in/procand/sysare very good candidates. This way I can see the content of multiple files simultaneously.