Star Hype News.

Premium celebrity moments with standout appeal.

updates

find / | grep to find files containing git but exclude digital [duplicate]

By Sebastian Wright

I use find / | grep git to find repositories. Sometimes it finds lots of files which contain digital. It seems quite easy to use find / | grep -vi digital | grep git, but I believe that there's a chance of ignoring /home/auser/.../digital/.../gitrepo. I also would like to skip these directories:

/home/john/C_DRIVE/*
/proc/*

Is there a way to perform a search in such a way that a certain match is removed and after that search proceeds?

0

2 Answers

Since git repositories have a .git folder in them, look for those folders:

find / -type d -name .git
4

What you want is two switches, -not and -path. The -not operator will allow you to ignore a path that matches the patterns provided in -path like so:

find / -type d -name ".git" -not -path "/home/auser/*/digital/*" -prune
1