I have a VERY simple bash script written for my Kali Linux distro so I don't have to run apt-get update, apt-get upgrade, apt-get dist-upgrade, apt-get autoclean, and apt-get autoremove every time I open my laptop. After reading up on the syntax for a few days I still can't get it correct. I'm trying to add something in the script to format the terminal output where it will show "Errors" in RED. Any help would be greatly appreciated in adding something to my script which will show errors in RED for apt-get upgrade output. Thank you in advance.
Just FYI here is my two line script...
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoclean -y && apt-get autoremove -y
grep
highlights matches in red, so using this enclose the script in brackets and append| grep -iE '^|^.*error.*$'
. This gives( apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoclean -y && apt-get autoremove -y ) | grep -iE '^|^.*error.*$'
:grep '^'
makes sure every line is reported;grep -i '^.* error.*$'
matches the whole of every line containing "error" (any case); andgrep -E
allows both search strings in a single expression.