Tag logo

Run a bash command every project in a folder

Jul 22, 2024/
#bash
/-1 min

When the number of projects I had to manage increased, it became difficult to keep them synchronized. Especially when I wanted to search across all projects, I had to run

git pull
for each project individually. Then I created a snippet.

You can use

find -exec
to run your commands on all projects in a folder.

1find . \
2  -mindepth 1 \
3  -maxdepth 1 \
4  -type d \
5  -exec sh -c '(echo “\n${}” && cd {} && git pull)' \
6\;

Notes

  • Walks all folders at the depth you specify with
    mindepth
    and
    maxdepth
    .