Ben Reser contributed a bash script called wcgrep that is useful for greping in a Subversion working copy by ignoring the Subversion meta directories .svn/ and vi(m) backup files. We may find this script in the contrib/ directory in Subversion's release tar-balls. Similarly, we often need to ignore subversion meta directories when using find utility. A brute force way to throw off these directories would be post-processing by grep -v like below:

find . -ctime 1 | grep -v '/\.svn/' | grep -v '/\.svn

However, typing these two extra grep command each time is troublesome. So I wrote a Broune Shell script that wrap the concept and optimized some by using -prune like Ben Reser did. There are three key points to this script:

  1. Separate the first argument, the initial path argument, and the rest since we need to insert extra find commands between the path and user given find commands.
  2. Still need one more grep -v post-processing since the -prune trick cannot remove .svn/ directories.
  3. Be sure to use -f for sh at the first line of this script to disable pathname expansion (noglob), or duplicated expansions will mess up the final find statement.

Like wcgrep, I call this script wcfind.sh and alias it to wcfind. Using it is easy, just like using normal find command:

wcfind . -ctime 1

And finally I can use the following command to easily moving files around like:

wcfind src/ -type f | xargs -n 1 -I @ svn mv @ ../backup/src/

If you're interested in wcfind.sh, you may find it here in my ADE project site.