Search code examples
linuxbashfilesystemsfindfile-globs

how do i find all files with the same name in all subdirectories


I want to find all the different .gitignore files I have to combine them into one.

I tried something like find */**/.gitignore but that came up with nothing.

All the files are in sub directories of my current dir, as well as the current directory.

I am using Bash on linux


Solution

  • find -name .gitignore
    

    That should do

    Since you are using bash:

    shopt -s globstar
    echo **/.gitignore
    

    From man bash:

       globstar
              If set, the pattern ** used in a pathname expansion context will match a
              files and zero or more directories and subdirectories.  If the pattern is
              followed  by  a /, only directories and subdirectories match.