AIX - find a specific word in a file of directories and sub-directories

Posted on 2012-08-10
Last Modified: 2012-08-10
I'm trying to find keyword ibds under a filesystem structure. I would like the command to search within files for the keyword ibds.

I tried, find . -exec grep -l 'ibds' {} \;

But, I'm not sure if that will work. Can anyone help?
Question by:AIX25
    1 Comment
    LVL 68

    Accepted Solution

    Your command should indeed work fine. You should restrict "find" to process only files, not directories etc., however. Use "-type f" to achieve this.

    Besides that, this will run faster:

    find . -type f | xargs grep -l 'ibds'

    To find just the whitespace-delimited word " ibds " and not the string "ibds" inside a longer one (like "libibds.a") use the "-w" flag of grep:

    find . -type f | xargs grep -wl 'ibds'

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (, discussed installing the Solaris Operating S…
    I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now