I basically want to find all git repos that have neither a .gitattributes nor a .gitignore file at the root.I used find . -type d '!' -exec test -e {}/.gitignore ';' -print to find it but it lists out all the directories instead of only the top level git directories.My directory tree looks like this:GitHub _Clones|   repo1 (has .gitignore)|   repo2 _Forks|   repo1 (has .gitattributes)|   _For-Later|       repo2|       repo3 myrepo1 (has both) myrepo2 (has both)... myrepo10In such a layout I would want the output to be _Clones\repo2, _Forks\_For-Later\repo2, _Forks\_For-Later\repo3 and myrepo10.I've tried using depth parameter for find but that is a variable for each directory!
Find all git repos that do not contain any one of .gitignore and .gitattributes
shell script;find;git
To list the root directories of git repositories, I use the following:find . -name .git -print0 | xargs -0 dirnameA variant finds all folders containing .gitignore:find . -name .gitignore -print0 | xargs -0 dirnameDetermining git repositories whose root doesn't contain .gitignore is then simply a set operation on the two sets of folders:comm -23 <(find . -name .git -print0 | xargs -0 dirname | sort) <(find . -name .gitignore -print0 | xargs -0 dirname | sort)This compares the two sets of folders (which have to be sorted) and lists those which only appear in the first set. The <() operation is process substitution and allows the output of any command to be used as input to another command instead of a file.Replace .gitignore with .gitattributes above to find the git repositories which don't contain .gitattributes in their root directory...To get the final output you're after, combine both:comm -23 <(comm -23 <(find . -name .git -print0 | xargs -0 dirname | sort) <(find . -name .gitignore -print0 | xargs -0 dirname | sort)) <(find . -name .gitattributes -print0 | xargs -0 dirname | sort)