Search file contents in UNIX

I found myself having to search through the contents of a bunch of files in Unix the other day, and wanted to find a command to do it for me.

Cue some Googling, and I found exactly what I was looking for here.

find . -name "*" -exec grep -l "somestring" {} \;

1 thought on “Search file contents in UNIX”

  1. You may also like:

    find . -name “*” -exec grep -H –line-number “export” {} \;

    -H prints the file name for each match
    –line-number prints the line number of the matching occurence within the file

    Hope you’re well buddy.

Leave a Reply

Your email address will not be published. Required fields are marked *