1

Does find allow multiple directories and should they be quoted.

find "${dirlist[@]}" "${ftype[@]}" -type f  
Isabel
  • 79

1 Answers1

6

Yes, find allows you to search starting at one or several directory paths (in fact, any pathnames whatsoever works, they don't strictly need be paths to directories):

find dir1 dir2 dir3 -type f

That command would find all regular files in or below any of the three listed directories.

If the list of search paths is kept in an array, as in your question, the expansion of that array into a list of directory paths should be quoted. The code that you show is correct in this respect:

dirs=( dir1 dir2 dir3 )

find "${dirs[@]}" -type f

I'm uncertain what your ftype array holds, so I will not comment on that. If it contains another list of directories, then you are using it correctly, at least from just seeing that single line of code.

Related:

Kusalananda
  • 333,661