2
votes

I know how to color the output of grep, ls (in 256 colors!), prompt and tail. But what would really enhance productivity of a heavy find user like me would be colored find output.

Does such a thing exist? Some web searching yields no promising results for me. It doesn't help that 'find' is such a generic word :-)

3

3 Answers

3
votes

As far as I know find doesn't have this built in. For situations like these I like to use grc (check out http://manpages.ubuntu.com/manpages/gutsy/man1/grc.1.html). Hope that's helpful!

1
votes

grc would suit fancy coloring but simple highlighting can be done with grep. The trick is an extra -e ^ which matches an empty bit of each line.

$ ls
dull.txt interesting.txt really_interesting.txt
$ find * -printf '%a %p\n' | grep --color=auto -e ^ -e "[a-z_]*interesting"
Wed Feb 8 17:01:49.0685605700 2012 dull.txt
Wed Feb 8 17:01:49.0686582300 2012interesting.txt
Wed Feb 8 17:01:49.0688535400 2012really_interesting.txt

Shame about color in Markdown. I've used bold above where I have red in my console.

There are plenty of alternatives to the --color=auto I've used in my grep example.

1
votes

You can send the output of find to grep and then play with the colors as needed:

find * -iname *Test* -exec ls --color=auto -d {} \; | grep -i Test

You can also create an alias like below:

myfind() { find * -iname "*$1*" -exec ls --color=auto -d {} \; | grep -i $1 ; }