Kudithipudi.Org

September 23, 2008

HOWTO : Use find and grep together

Filed under: HOWTO,Linux — Vinay @ 1:23 am

If you ever wanted to search for a particular text in certain types of files in Linux, you can use the following combo of find and grep

find / -name \*.xml -type f | xargs grep -i “text_to_search”

I used *.xml (note the \ before *) as the mask in the filename to look for all XML files.. then I piped this to grep using xargs.

A colleague pointed out that I can do the same by using

grep -r o-i “text_to_speech”

2 Comments »

  1. I’ve always used
    grep -r --include="*.xml" "text_to_speech" .

    Comment by Ray Krueger — September 23, 2008 @ 6:59 am

  2. It at the “code” tag stuff, grrr

    grep -r –include=”*.xml” text_to_speech .

    Comment by Ray Krueger — September 23, 2008 @ 7:00 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress