Format CSV file from a shell script

I have a shell script which creates a CSV files. there are 3 fields, field1, field2 and comp. I will generates the values for field1 and field2 and Want to compare both. If field1>filed2 then comp should be success written in green in CSV file, else it should fail in red color. How can I change the colors in csv file from unix.

Thanks in advance.

csv files don't have colors... Do you mean xls files? You can't create xls files by using just shell scripting

You can try ANSI escape sequences like

$ echo  "\033[0;31mHello world\033[0m"
Hello world

so, is there any way to get colored cell as I mentioned above ?

---------- Post updated at 06:05 AM ---------- Previous update was at 06:04 AM ----------

it will give me colored text in the putty/prompt, but not in CSV file. I want in CSV file.

As such ANSI colors will help you only on terminals, I dont think the colors will show up if the file is opened with excel application

You can check for Perl modules that writes to excel. Its available in CPAN.

Can you explain me further, how to take the csv file to perl and make appropriate changes?