Hi there,
I'm fairly new to bash scripting and already having trouble. I need a script that can print some series of strings in colors based in the information of a file, for simplicity let's say it only does:
Code:
#!/bin/bash
printf "\e[1;31;32m%-10s\e[00m" "OK"
When you execute this in the command line it prints a bold green 'OK'. So far so good.
Now, I need to check the output of the script over time using the command
watch. The problem then arises.
watch seems to ignore the escape codes and just prints:
Is there any way to fix this?
If not, how can I check inside the script if it is being executed from a command? (
watch in this case) So I can print without color for those cases.
Thanks for your time in advance!