Skip to content

Instantly share code, notes, and snippets.

@msimerson
Created March 30, 2024 03:57
Show Gist options
  • Save msimerson/10da36288e12dab179cc1226ebbf184a to your computer and use it in GitHub Desktop.
Save msimerson/10da36288e12dab179cc1226ebbf184a to your computer and use it in GitHub Desktop.
gfind
gfind() {
find -E . \
-type d -regex '.*\.(git|svn|blib|build)$' -prune -o \
-type f -name '*.min.js' -prune -o \
-type d -name node_modules -prune -o \
-type d -name bower_components -prune -o \
-type d -name vendor -prune -o \
-type d -name coverage -prune -o \
-type d -name ignore -prune -o \
-type d -name _site -prune -o \
-type d -name bats -prune -o \
-type d -name test_helper -prune -o \
-type f -regex '.*~' -prune -o \
-type f -iregex '.*\.(jpeg|jpg|gif|pdf|png|gz|tgz|zip|mov|mp4|m4a|pages)$' -prune -o \
-type f -print
}
@msimerson
Copy link
Author

I also have an older sfind version of it that excludes .svn (subversion) metadata. Since I mostly use this shell command for grepping file contents (grep PATTERN `gfind`), excluding binary file types is also useful.

gfind() {
    find -E . \
        -type d -regex '.*\.(git|svn|blib|build)$' -prune -o \
        -type f -name '*.min.js' -prune -o \
        -type d -name node_modules -prune -o \
        -type d -name bower_components -prune -o \
        -type d -name vendor -prune -o \
        -type d -name coverage -prune -o \
        -type d -name ignore -prune -o \
        -type d -name _site -prune -o \
        -type d -name bats -prune -o \
        -type d -name test_helper -prune -o \
        -type f -regex '.*~' -prune -o \
        -type f -iregex '.*\.(jpeg|jpg|gif|pdf|png|gz|tgz|zip|mov|mp4|m4a|pages)$' -prune -o \
        -type f -print
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment