non GNU ls and color on a unix system

Where I work, ls --color is not legal, and only throws illegal option errors back at me. So last week I set out to get some colors going. I have two options:

1) Find someone else's script who's already done this. Well, after 5 days of searching and finding hundreds of references to "ls --color" and nothing as far as someone else writing a script to provide color, this does not seem like an option.

2) Write my own script to do this. Since I mostly program in non-scripting languages, I thought "this can't be too difficult." Searching through man pages has led me to believe I can pipe the outputs of "ls -CF" into a script and then color each file based on what character it ends with. This poses some problems: what existing unix program can I use ( awk? ) to modify each word using regex, and what about non-standard file names that contain spaces?

This is my first scripting project that contains some meaningful depth, and otherwise being fairly new to scripting, I'm at a loss as to just how to do this. However, I do learn fast. Can anyone provide any tips/guidance as to how I can do this?

Not sure if this is what you want, but you may want to look at BSD's ls. They use the -G flag for colorized output.

http://www.freebsd.org/cgi/man.cgi?query=ls&apropos=0&sektion=0&manpath=FreeBSD\+5.3-RELEASE\+and\+Ports&format=html

Nope, that doesn't help. The ls I have available for use has no coloring capability whatsoever. If it does, then it isn't specified anywhere in the man, nor has any switch I've tried to use done it for me.

Which is why I'm probably going to have to write something myself.

*bump*

I take it noone has any ideas they'd like to share?

Here's an idea: read the rules which say:

(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

Not sure that there is any "meaningful depth" here...

ls -l | awk '
/^d/{printf "\033[34m%s\033[0m\n",$0;next}
/^l/{printf "\033[35m%s\033[0m\n",$0;next}
$1~"x"{printf "\033[36m%s\033[0m\n",$0;next}
{print}'

Getting people to RTFM is hard enough, getting myself or anyone else to RTFR is next to impossible. However, thank you for quoting the rules.

Ygor,

Thank you. I've been sidetracked with real work the last week or so, and haven't been able to anything for this little project of mine. Your posted code will definately save me some time.

Much appreciated,
Clinton