DISQUS

Tech-Recipes: Recursive grep | UNIX | Tech-Recipes

  • htihan · 4 years ago
    Thank you so much,

    It is one of those days.. I spent almost an hour for this.....

    Best, peace...
    Hal
  • Anonymous · 4 years ago
    that's great and all, but you dont get filenames
  • seacoder · 4 years ago
    find . -name "*" -exec grep <pattern> {} /dev/null ;
  • Anonymous · 4 years ago
    find /users/ -type f -name "*" -exec grep -ls sqlload {} ;
    It gives output like this:
    /users/hattb/shirley_test_file

    The -type f switch tells it to only look in text files.
    If you want to redirect the output to a file:
    find /users/hattb -type f -name "*" -exec grep -ls sqlload {} ; >out.txt

    Hope this helps,
    Shirley
  • Anonymous · 3 years ago
    It's so great. Thanks.
  • Anonymous · 2 years ago
    find|xargs grep 'search text'

    is easier to type :-)

    xargs rocks.
  • Anonymous · 2 years ago
    For those of you with a really stripped down config with no xargs and a find that doesn't support -exec, the old fashioned way:

    for i in `find <path>`; do grep <pattern> $i; done
  • Lee · 10 months ago
    This is a fantastic tip, thank you!