Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Using grep with subdirectories

  • 05-07-2000 1:13pm
    #1
    Registered Users, Registered Users 2 Posts: 16,413 ✭✭✭✭


    Got it working with:
     find ./ -name "*.[c|h]" -print|xargs grep TPF
    

    Al.


Comments

  • Registered Users, Registered Users 2 Posts: 3,744 ✭✭✭deRanged


    you know you can use commands in the find statement?
    ie
    find . -name "*.[c|h]" -exec fgrep -l {} \;

    might be handy.


  • Closed Accounts Posts: 102 ✭✭OctaviaN


    Yeah as above
    lol smile.gif


  • Registered Users, Registered Users 2 Posts: 16,413 ✭✭✭✭Trojan



    deRanged: that's what I said... cept using | rather than exec...

    Cheers, anyway...

    Al.


  • Registered Users, Registered Users 2 Posts: 16,413 ✭✭✭✭Trojan


    Hi all,

    can any of you Unix wizards tell me how to grep through several subdirectories? I can't find a grep option to do the same.

    I tried the find command as follows (I was looking for the string "TPF":
    find ./ -name "*.[c|h]" -print| /dev/null grep TPF
    
    but this didn't work.

    Any ideas?

    Cheers,
    Al.


Advertisement