Consider the following command to find and update all git repos in a particular directory:
find . -type d -name .git | while read src_dir; do
my_git_update "${1}";
done;
Assume that a repo cannot contain other repos, so there is no point in going deeper into that directory. I am not using sub-modules and such, so nested cases don't count for this question. So in general...
Is there a way to tell find
to stop recursing into a directory once a match is found?
Based on my searches, the answer may lie with -prune
, but I can't figure out exactly how to use it in my case.
Unix 'find' without descending into matched directories is not a duplicate, despite the title. It focuses on deletion of sub-directories - that solution is not applicable here.
Copyright License:
Author:「metacubed」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/29118044/prevent-unix-find-command-from-recursing-into-matched-directories