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

Posted on 2012-08-10
Medium Priority
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

woolmilkporc earned 2000 total points
ID: 38281088
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

569 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