UNIX find grep

I am always hunting for this, and so I’m going to put it here so I can remember!

This command is great:  find . -exec grep -l hello {} \;

Essentially, it does this:

  1. find all files starting in the current directory (“.”)
  2. for each file found execute “grep -l hello”
  3. grep -l will print file names — with full relative path — that match the grep criteria

This is great, as a programmer, to try and figure out which file had a certain word (or phrase, or Regular Expression pattern) in it.

There are also a couple of other pages with a large set of references here and here.

Advertisements

About John

I write about technology interests, cooking, and my own writing (sci-fi and fantasy... sometimes both). I try to keep things light, but sometimes I get side-tracked on an issue that I feel strongly about. No offense is meant, I'm just like any other person who feels strongly about something when I write. View all posts by John

Comments are disabled.

%d bloggers like this: