1

When I run

find -maxdepth 1 -type d -name 'iptp*' -execdir bash -c "ls {}" \;

I get a listing of all dirs named iptp*

When I run

find -maxdepth 1 -type d -name 'iptp*' -execdir bash -c "git status {}" \;

I get

fatal: Not a git repository (or any parent up to mount parent )
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I seems like git status is run in the parent dir where find was started.

What do I make wrong?

Quasímodo
  • 18,865
  • 4
  • 36
  • 73
macbert
  • 143

1 Answers1

3

With -execdir, the command is run in the directory containing the match, i.e. the parent directory of the directory whose name starts with “iptp”.

You could instead look for .git with a path matching iptp*:

find -maxdepth 2 -type -d -name .git -path "*/iptp*/*" -execdir git status \;
Stephen Kitt
  • 434,908