Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Using grep with subdirectories

  • 05-07-2000 01:13PM
    #1
    Registered Users, Registered Users 2 Posts: 16,415 ✭✭✭✭


    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,415 ✭✭✭✭Trojan



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

    Cheers, anyway...

    Al.


  • Registered Users, Registered Users 2 Posts: 16,415 ✭✭✭✭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