
當我跑步時
find -maxdepth 1 -type d -name 'iptp*' -execdir bash -c "ls {}" \;
我得到了所有名為 iptp* 的目錄的列表
當我跑步時
find -maxdepth 1 -type d -name 'iptp*' -execdir bash -c "git status {}" \;
我明白了
fatal: Not a git repository (or any parent up to mount parent )
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
我似乎git status
是在啟動 find 的父目錄中運行的。
我做錯了什麼?
答案1
使用 時-execdir
,該命令在包含匹配項的目錄中運行,IE名稱以“iptp”開頭的目錄的父目錄。
您可以.git
使用小路匹配iptp*
:
find -maxdepth 2 -type -d -name .git -path "*/iptp*/*" -execdir git status \;