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


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.

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

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

while IFS=$'\t' read -r -d '' perms name
    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")
| improve this answer | |

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.