Unix / Linux Command question

I'm building a tar file on a directory that contains subversion (".svn") subdirectories.

The problem is I want to tar us everything UNLESS!! it lives in a .svn sub directory.

The command I'm currently using is:
  tar -cvf mytar.tar myRootDir

How do I filter out any subversion directories?
tmonteitAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
slyongConnect With a Mentor Commented:
Hi,

I am not sure if I understand you correctly that you want to tar all the files "except" those that under the .svn subdirectory.  If that is the case, you can use the "exclude" flag:

$ tar -cvf mytar.tar myRootDir --exclude "myRootDir/.svn"
0
 
ozoCommented:
find myrootdir -name '*.svn*; -prune -or \! -type d -print | xags   tar -rvf -X mytar.tar
0
 
Duncan RoeConnect With a Mentor Software DeveloperCommented:
GNU tar has its own mechanism to filter out unwanted directories - no need to use find, as slyong mentioned.
If you want to exclude *all* .svn directories, use

tar -cf mytar.tar --exclude .svn myRootDir

tar's default is *not* anchored - i.e. .svn can be a component anywhere in the directory tree
0
 
tmonteitAuthor Commented:
sylong had the right answer but duncan had the better explanation :  points split.
0
All Courses

From novice to tech pro — start learning today.