Trying to color my command output, I am stuck in understanding the difference between
- logging into my machine and seeing the MOTD
- running run-parts on /etc/update-motd.d/
I created this test-script to illustrate:
#!/bin/bash
W="\e[0;39m"
R="\e[1;31m"
G="\e[1;32m"
echo -e "This is a test for ${G}GREEN${W} and ${R}RED${W}"
echo -e "Lets highlight some colors aight?" | grep --color 'ight'
When I run it directly, both lines have colors.
root@server:/etc/update-motd.d# ./test-file
When I run it via run-parts, both lines have colors.
root@server:/etc/update-motd.d# run-parts ./
BUT when I log in, only the first line gets colored!
How can I have colored greps or even debug this?