1

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

3

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.

  • Super! And in Ruby too! – Zabba Apr 20 '11 at 15:33
3

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")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.