# Using find command

**URL:** <https://community.unix.com/t/using-find-command/141212>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [February 5, 2002, 11:00am UTC](https://community.unix.com/t/using-find-command/141212 "2002-02-05T11:00:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jo\_aze](https://community.unix.com/letter_avatar/jo_aze/32/6_22734026db12803ebb3e059622ac3534.png) [@jo\_aze](https://community.unix.com/u/jo_aze)\
**Post date:** [February 5, 2002, 11:00am UTC](https://community.unix.com/t/using-find-command/141212/1 "2002-02-05T11:00:26Z")

</div>

Hy,  
Does someone know how to setup "find" command allowing to find all files or directories according to a specific filter whatever case sensitive (I'm working on AIX platform 4.3.3).  
Example:  
find / -type d -exec grep ....  
Or perhaps using regular expresssion  
find / -type d -name \*...$name...\*

Thanks for your help

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [February 5, 2002, 5:06pm UTC](https://community.unix.com/t/using-find-command/141212/2 "2002-02-05T17:06:59Z")

</div>

Do a search on [www.unix.com](http://www.unix.com) - search for find case sensitive. Livinfree and others seem to have answered this type of question before.

If that doesn't help, respond to this again.

---

<div class="post-metadata">

**Author:** ![jo\_aze](https://community.unix.com/letter_avatar/jo_aze/32/6_22734026db12803ebb3e059622ac3534.png) [@jo\_aze](https://community.unix.com/u/jo_aze)\
**Post date:** [February 6, 2002, 4:22am UTC](https://community.unix.com/t/using-find-command/141212/3 "2002-02-06T04:22:55Z")

</div>

Thanks for this suggestion but i've found nothing that i've not yet be done ...  
In fact, i'm searching for a substitute of "-iname" option. I'd like to use a loop using a variable ($var for example) which should be passed to search command like "find":  
Ex.:  
for var in listing\_var  
do  
find . -name $var ... ...  
done

I've thought about syntax like :  
find . -type d -name \*[A-z][$var] ...  
or  
find . -type d -exec grep -i $var  
But i've some problem to implement it.

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [February 6, 2002, 10:15am UTC](https://community.unix.com/t/using-find-command/141212/4 "2002-02-06T10:15:05Z")

</div>

Does $ find . -print | grep -i $1 take care of it?

---

<div class="post-metadata">

**Author:** ![jo\_aze](https://community.unix.com/letter_avatar/jo_aze/32/6_22734026db12803ebb3e059622ac3534.png) [@jo\_aze](https://community.unix.com/u/jo_aze)\
**Post date:** [February 6, 2002, 10:26am UTC](https://community.unix.com/t/using-find-command/141212/5 "2002-02-06T10:26:42Z")

</div>

This method filters entirely the path of your search. Ex.:  
find . -type d | grep -i toto  
will show all directories and sub-directories containing "toto" in their paths like:  
./toto  
./test/ToTo  
./toto/test (\<- My PB !)

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [February 6, 2002, 10:42am UTC](https://community.unix.com/t/using-find-command/141212/6 "2002-02-06T10:42:54Z")

</div>

I'm not sure if you now have what you need or are looking for something else.

Original problem stated:  
setup "find" command allowing to find all files or directories according to a specific filter whatever case sensitive

The suggested fix will do that.

To add it to your script would be simple.

If you need more than that, respond with more information.  
If you are looking to filter more out of the output from the find comand (piped to grep) you may need to be more specific in what you are greping for (add another grep with -v option to get rid of what you don't want?)

---

<div class="post-metadata">

**Author:** ![jo\_aze](https://community.unix.com/letter_avatar/jo_aze/32/6_22734026db12803ebb3e059622ac3534.png) [@jo\_aze](https://community.unix.com/u/jo_aze)\
**Post date:** [February 6, 2002, 11:43am UTC](https://community.unix.com/t/using-find-command/141212/7 "2002-02-06T11:43:05Z")

</div>

Thank to be indulgent about my english ...  
Yours suggestions and remarks are correct and i noticed that precisions miss so:

My complete problem is that i'm trying to set up a method (using find command for example) to filter all directories and sub-directories containing a predefined substring (like "toto") declared in a variable (because of a loop. see above for details).

I try first to implement find command with "-exec" option and combine it with grep command:  
find . -type d -exec grep ... ... {} \;  
But it seems not to be the good way.

...

While writting this reply, i thought about another way of solution. Perhaps have you any suggestions to improve and validate it:

find . -type d -exec basename {} \; -ls | grep -i "toto" | nawk '{print 11}'
