2013-12-18 143 views
1

在我的git仓库中,我在根目录下有一个小目录结构,在.git目录下有一个很大的目录结构。我想使用find命令获取$(REPO_DIR)下所有目录的列表,但不包括$(REPO_DIR)/.git(含)以下的任何目录。我想是这样如何查找除.git目录下的所有目录?

find $(REPO_DIR) -type d ! -name ".git" 

find $(REPO_DIR) -wholename ".git" -prune -type d 

但遗憾的是没有和预期一样,有什么建议?

回答

2

尝试:

find . -type d -not -iwholename '*.git*' 

或:

find . -type d -not -path './.git*' 
+0

,谢谢您的回答 – e271p314

0

作为替代方案,如果你正在使用bash,你可以打开extglob模式。

shopt -s extglob 

这将允许您(从内$(REPO_DIR))做:

find !(.git) -type d 

看到这个答案的全部细节:现在好多了https://stackoverflow.com/a/217017/24

+0

对不起,没” t工作,它从makefile中的'shell'命令运行 'VPATH:=。 $(shell找到$(REPO_DIR)-type d -not -wholename“* .git *”)' – e271p314

+0

啊,那肯定不会为你工作的。猜猜'$(REPO_PATH)'变量格式应该让我知道...... – sanmiguel

相关问题