From 55e2d4fa75837e3e79b8639050c640998b209bc6 Mon Sep 17 00:00:00 2001 From: zxcxz7 Date: Thu, 26 May 2016 23:17:03 +0900 Subject: [PATCH] Update tip and add an alternative Update find command to exclude hidden directories. Add GNU find command --- README.md | 12 +++++++++++- tips.json | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dac0a86..4e30d1b 100644 --- a/README.md +++ b/README.md @@ -698,7 +698,17 @@ git rebase --interactive HEAD~2 ## List of git repositories in multiple directories. ```sh -find /path1 /path2 /path3 -regex '.*\.git' -type d -print0 | xargs -0 -I {} dirname {} +find -E ${targetdir} \( -regex '.*/\.git + -not -regex '.*/\..*/\.git + \) -type d -print0 | xargs -0 -I {} dirname {} +``` + + +__Alternatives:__ +```sh +find ${targetdir} -regextype posix-egrep \( -regex '.*/\.git + -not -regex '.*/\..*/\.git + \) -type d -print0 | xargs -0 -I {} dirname {} ``` diff --git a/tips.json b/tips.json index 107cbe7..6aa8bf7 100644 --- a/tips.json +++ b/tips.json @@ -313,5 +313,6 @@ "tip": "git rebase --interactive HEAD~2" }, { "title": "List of git repositories in multiple directories.", - "tip": "find /path1 /path2 /path3 -regex '.*\\.git' -type d -print0 | xargs -0 -I {} dirname {}" + "tip": "find -E ${targetdir} \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}", + "alternatives": ["find ${targetdir} -regextype posix-egrep \\( -regex '.*/\\.git$' -not -regex '.*/\\..*/\\.git$' \\) -type d -print0 | xargs -0 -I {} dirname {}"] }]