开发者

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

开发者 https://www.devze.com 2023-03-15 10:04 出处:网络
I want to find all the different .gitignore files I have to combine them into one. I tried some开发者_JS百科thing like find */**/.gitignore but that came up with nothing.

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

I tried some开发者_JS百科thing 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


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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消