Search code examples
findfilepathglob

Find all files whose absolute path ends in a certain pattern


Using find and globbing, how can I find all files in a given directory whose absolute path (or even just path relative to the given directory) ends in /foldername/otherfolder/*.php?


Solution

  • Assuming you mean files, for which the whole path ends in /foldername/otherfolder/*.php, you can just use the -regex option

    find -regex '.*/foldername/otherfolder/[^/]*.php'
    

    Where -regex will operate on either the relative or absolute path (depending on what you provided, with default being relative to $PWD) and use emacs type.