Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script that operates on 4 folders.

Because they are completely independent, I'm passing in the folder path to a function and then forking that function. It works, but the output to the console is an unreadable disaster.

The main problem is that I cannot tell which folders have been processed and which ones are still going.

One way I have thought of around this problem is to assign a color to the output based on the folder - Red, Green, Blue and Yellow. The idea is that when there is only red output, I know only folder 1 is still being processed.

All my googling about setting colors in bash talks about using echo or passing in the color for specific functions like grep and ls.

Is there a way to set the color at the start of a function?


   set_color $2

#in a loop, process my folders using process_folder $folder $color
share|improve this question
Sorry, I submitted a close vote, it's a bash script which is on topic. Sorry! – Dave Jan 11 '13 at 9:16
up vote 0 down vote accepted

Is there a way to set the color at the start of a function?

It is possible,

echo -e "\e[00;31mRED"

but it could mix colors and make things harder to read. Color your output only.

echo -e "\e[00;31mRED\e[00m"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .