Thursday, May 29, 2008

to filter .svn view

find is a great tool. But, find treats all files and all directories equally including .svn dirs. Suppose we need to see the directory structure of a certain directory and issue this command:

$ find . -type d

If the current directory is under svn version control, find will show many .svn directories, too. Well, since find is a great tool, it will have some filtering functions, too. 'man find' and we can come up with this to filter out .svn.

$ find . -name .svn -prune -o -print

Hmmm.. We select non-.svn by inverting the result. But, we don't know it is a file or directory. Unix has another great tool called egrep.

$ find . -type d | egrep -iv ".svn"

We used invert matching not in find, but in egrep. Inspecting a directory will be much easier with these two tools. For svn specific, we can use 'ls' command on svn.

$ svn ls -R

But, ls isn't good for distinguish file or diectory.

No comments: