Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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()
{
   ??
}

process_folder()
{
   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 Rook Jan 11 '13 at 9:16

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.