Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find files in multiple directories

Tags:

linux

find

bash

I am using RHEL. In my current folder there are sub folders. I need to find where a file is in the subfolders. The files may be in one or more.

I am using this but it iterates infinitely:

for f in ./{Failed,Loaded,ToLoad}; do find -name 'file';  done

How to get this right?

like image 764
case Avatar asked Nov 16 '12 11:11

case


1 Answers

The syntax of your for-loop is incorrect.

It should be:

for f in Failed Loaded ToLoad
do
    find "$f" -name 'file'
done

But you don't need a loop. It can simply be done like this:

find Failed Loaded ToLoad -name 'file'
like image 59
dogbane Avatar answered Oct 20 '22 14:10

dogbane