How do I filter dotfiles out recursively using find in bash?
I've searched far and wide but can't seem to find the answer to this seemingly simple question!
I have a directory that contains some dotfiles (they happen to be .git but the could ea开发者_运维问答sily be .svn and maybe even something else) and some non-dotfiles.  I'm searching for a general function that will list all subdirectories of this directory, except the ones beginning with a period ..
I'm thinking it's some variant of find . -type d but I've tried several incantations and come up short.
Something like
def find_files(listing, dir):
    for entry in listdir(dir):
        if isdir(entry) and does_not_begin_with_dot(entry):
            listing.append(entry)
            find_files(listing, entry)
(Surprised nobody's asked this - maybe there's a more bash-ish way that I'm not seeing?)
find . -type d | grep -v '/\.'
...or...
find . -type d -a ! -name '.?*' -o -name '.?*' -a ! -prune
Give this a try:
find . -mindepth 1 -name '.*' -prune -o \( -type d -print \)
I am not sure if this is what you want, but to recursively list all subdirectories in bash I usually do something like
ls -R | grep /
Works a lot faster than some find options I tried. The disadvantage is that using ls I get extra colon at the end, but that is not a case for me.
//edit Ok, I tried other find answers from here and they work quite fast... but they are harder to remember than ls. :)
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论