(bare with me as I am sort of new with scripting)
I am trying to figure out how to run a script that does a basic chkconfig and to get only those services that are running, but changing the color of "on" to red in my output file.
Here is what I am working with so far:
Quote:
#/bin/bash
RED=$(tput setaf 1)
BLK=$(tput setaf 0)
echo "" > /tmp/services.txt
echo "Here are the running services. Those with RL's that are turned on are in ${RED}red${BLK}:" >> /tmp/services.txt
echo "" >> /tmp/services.txt
chkconfig --list | grep <colon_symbol>on | sort >> /tmp/services
|
the results would return something similar to (I am only listing a couple of services for shortness) when the red is working:
Quote:
httpd 1-off 2-off 3-on 4-off 5-on 6-off
sshd 1-off 2-off 3-on 4-off 5-on 6-off
|
*I had to substitute a "-" and <colon_symbol> for ":" in front of the on's, because the forum thought they were smiley faces (i.e.

n)
as you can see, I have no idea how to make the "on" to be red while the rest of everything remains in black text. I have been trying to read up on sed and awk, but it is still pretty much a mystery to me right now. There will be other things in the output file that I wouldn't want a rogue "on" to be in red, so just the instances of "on" in that one chkconfig return.
Thanks.