Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • 1
    This is really cool. And I thought my solution is clever ;-) Commented Sep 13, 2018 at 9:13
  • @Stephen Kitt You mentioned -name .git -prune to exclude directories. Is it better to use -not -path "*/.git/*" Commented Sep 13, 2018 at 9:39
  • 1
    @Nikhil -not -path "*/.git/*" checks all the files and directories inside .git, which can take a little while, whereas -name .git -prune avoids descending into the directory at all; the latter is more efficient. Commented Sep 13, 2018 at 9:49
  • 1
    @Nikhil no: -print is the default action, used when no other expression is given. Here the find command includes other expressions (-exec, -prune, and -name) so we need to specify -print explicitly. Try removing -print: the find command won’t output anything. find . and find . -print are equivalent as complete commands, not as portions of commands. Commented Sep 16, 2018 at 13:14
  • 1
    @Nikhil your very first test in that command limits everything else to files, so you’ll never prune any directory. You need to split the tests up to prune directories and then look for index.md: find . \( -type d \( -exec [ -f {}/.git ] \; -o -name "Rendered" \) -prune \) -o \( -type f -name index.md -print \). Commented Sep 22, 2018 at 23:01