![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vim color | mirusnet | Shell Programming and Scripting | 1 | 01-06-2008 09:43 AM |
| ls color | andryk | AIX | 3 | 05-14-2004 12:26 AM |
| What is unix and is linux a unix system | Perderabo | Answers to Frequently Asked Questions | 0 | 03-13-2004 06:22 PM |
| Difference between UNIX operating system and Unix Open Server | Manjit | UNIX for Dummies Questions & Answers | 1 | 01-09-2002 05:21 PM |
| Unix Web color palette??? | jmaxmad | UNIX for Dummies Questions & Answers | 1 | 12-05-2000 03:26 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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?q...ts&format=html |
|
#3
|
|||
|
|||
|
Quote:
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. |
|
#4
|
|||
|
|||
|
*bump*
I take it noone has any ideas they'd like to share? |
|
#6
|
||||
|
||||
|
Not sure that there is any "meaningful depth" here...
Code:
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}'
|
|
#7
|
|||
|
|||
|
Quote:
|
|||
| Google The UNIX and Linux Forums |