2

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

loosecannon
  • 7,683
  • 3
  • 32
  • 43

2 Answers2

8
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.
sehe
  • 374,641
  • 47
  • 450
  • 633
2

Try this

find /home/user1 -name 'result.out' 2>/dev/null

In your case

find /<your DIR> -name '*.gitignore' 2>/dev/null

This results in

/home/user1/result.out
/home/user1/dir1/result.out
/home/user1/dir2/result.out
Rahul
  • 76,197
  • 13
  • 71
  • 125