Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In the rwx permissions that are listed by ls -l, is it possible to put the first set of rwx in red, the next in blue and the third in green?

For example, is the following possible:

enter image description here

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Have a look at Arbitrary Command Output Colourer. It can, well, colourize arbitrary command outputs. There is no working DEB archive, but installation trivial (once you have ruby installed). Configuration is via regular expressions and can do whas you want.

share|improve this answer
    
Super! And in Ruby too! –  Zabba Apr 20 '11 at 15:33
add comment

Parsing ls output is notoriously error prone, but here's a working version based on find:

while IFS=$'\t' read -r -d '' perms name
do
    echo "${perms:0:1}$(tput bold; tput setaf 1)${perms:1:3}$(tput setaf 4)${perms:4:3}$(tput setaf 2)${perms:7:3}$(tput sgr0) ${name}"
done < <(find . -maxdepth 1 -printf "%M\t%f\0")
share|improve this answer
add comment

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.