The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-09-2005
Registered User
 

Join Date: May 2005
Posts: 5
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?
Reply With Quote
Forum Sponsor
  #2  
Old 05-09-2005
Registered User
 

Join Date: Mar 2005
Posts: 64
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
Reply With Quote
  #3  
Old 05-10-2005
Registered User
 

Join Date: May 2005
Posts: 5
Quote:
Originally Posted by jolok
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

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.
Reply With Quote
  #4  
Old 05-11-2005
Registered User
 

Join Date: May 2005
Posts: 5
*bump*

I take it noone has any ideas they'd like to share?
Reply With Quote
  #5  
Old 05-11-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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.
Reply With Quote
  #6  
Old 05-11-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
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}'
Reply With Quote
  #7  
Old 05-18-2005
Registered User
 

Join Date: May 2005
Posts: 5
Quote:
Originally Posted by Perderabo
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.
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0