1

Does find allow multiple directories and should they be quoted.

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

1 Answer 1

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:

1
  • Yes, it is just a list of specific directories.
    – Isabel
    Commented Aug 5, 2021 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .