2

I have to find all files on my computer except those which is under version control systems (git or SVN). I don't have to find not only meta files of VCS but all files in my working copy so i can't use something like

find . -type f \! -path \*/\.svn/\*;

Please, help me, cause i haven't any idea about it.
Thank you!

kpotehin
  • 1,025
  • 12
  • 21

1 Answers1

1

I guess git status and svn status returns non-zero exit codes if current working directory (CWD) is not a repository. Since I don't think find can suppress output of its -exec invocations I would create

~/gitstatus.sh:

git status > /dev/null 2>&1
exit $?

~/svnstatus.sh:

svn status > /dev/null 2>&1
exit $?

Searching the files would then be done by issuing:

find . -type f '!' '(' -execdir bash ~/gitstatus.sh ';' -or -execdir bash ~/gitstatus.sh ';' ')'
Ztyx
  • 14,100
  • 15
  • 78
  • 114
  • I've just launched it, but output list contains only `find: ./System/Library/DirectoryServices/DefaultLocalDB/Default: Permission denied find: ./System/Library/User Template: Permission denied find: ./Users/Guest/Desktop: Permission denied find: ./Users/Guest/Music: Permission denied find: ./Users/Guest/Pictures: Permission denied find: ./Users/Guest/Public/Drop Box: Permission denied` etc. What's wrong? – kpotehin Sep 22 '12 at 09:35
  • The issue is that you don't have permission to list files in those directories. Based on the files listed, it looks like you are running a Mac. Try adding `sudo ` before `find` and entering your password and you should be fine. However, beware when using `sudo` because it gives the program you are running administrators' access! – Ztyx Sep 24 '12 at 21:07