We help IT Professionals succeed at work.

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

AIX25 asked
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?
Watch Question

Most Valuable Expert 2013
Top Expert 2013
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'