
In your “.With zsh (which I understand is now the default interactive shell on macOS), you could do: for f (**/*(ND-.)) (set -x grep pattern $f) Yeah, a bug, and a mildly annoying one at that.įortunately, there are shell aliases and that’s a far easier way to solve the problem. In fact, after some experimentation I conclude that the support for environment variables to get “grep” to always display the results in color. Seems like you should be able to specify something like “GREP_COLOR=always” or “GREP_COLOR=–color=always” but turns out neither works. Let me show you the difference…įirst off, here’s a search for which of my “dot” files (files in my home directory that begin with the ‘.’ to hide them from the Mac Finder) for the word “alias”:Īdd the parameter you reference, however, and it’s a lot easier to see where the pattern’s match appears:Ī look at the man page for “grep” offers some information, but it’s not very useful: The output, however, can be confusing, hence the desire for color. Or you can find all the files in a given directory that include the old battleaxe’s name: “grep -i brunhilda *”.

Want to find all the lines in your novel that reference Brunhilda? You can do that in grep with “grep -i brunhilda my.novel.txt”, for example. If you’re not sure about what “grep” does, it’s a pattern matching program. Now on to your query! What you’re asking about is a great feature in the modern “grep” program that has the program highlight the segment of each output line that matches the specified pattern. Which isn’t to say that I just want a command line interface, that’s definitely not true! But still, if I’m renaming a group of files, connecting to my Web server to edit a configuration file, or similar, command line is the way to go. I use the command line on my MacBook every single day and find it considerably faster and more efficient than using the graphical interface for administrative tasks in particular.


First off, glad you grabbed a copy of my book, the latest version of which is Learning Unix for Mac OS X Mountain Lion, and are finding it a good reference.
