Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I would like to search for a text in a file using find and grep command. For that I used following command find ./ -name *.C -exec grep "using ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2004
    Posts
    2

    using find and grep with pipe


    Hi,

    I would like to search for a text in a file using find and grep command. For that I used following command

    find ./ -name *.C -exec grep "using namespace cem" {} \; -print

    and it worked correctly.

    Just wondering why following command fails to do the same any pointers would be appreciated..

    find ./ -name *.C | gerp "using namespace cem"

    shishir

  2. #2
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    6
    Could it be gerp instead of grep?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    Assuming the 'gerp' was just a typo in your post the problem is you're searching the filenames and not the text within the files. Try this:

    Code:
    find ./ -name *.C | xargs grep "using namespace cem"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •