I have different folders with the name "templates" in various locations in my code. I need to list all the files within the folders with the name "templates"
All files within
templates folders, recursively:
find . -path '*/templates/*'
If you don't want the files in the subdirectories of
templates folders (except for the
templates/foo/templates/bar ones for course), you could use the
-regex extension of some
find . -regex '.*/templates/[^/]*'
If you only want regular files, add a
-type f. For any type of files except directory,
! -type d.
If you only care for the files' names and not the path leading to them, with GNU
find, add a
-printf '%f\n' (and maybe pipe to
sort -u, assuming the file names don't contain newline characters, to get unique names).