Solved

Unix / Linux Command question

Posted on 2007-04-08
4
253 Views
Last Modified: 2010-04-20
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?
0
Comment
Question by:tmonteit
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18874379
find myrootdir -name '*.svn*; -prune -or \! -type d -print | xags   tar -rvf -X mytar.tar
0
 
LVL 24

Accepted Solution

by:
slyong earned 200 total points
ID: 18874454
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
 
LVL 34

Assisted Solution

by:Duncan Roe
Duncan Roe earned 50 total points
ID: 18881339
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
 

Author Comment

by:tmonteit
ID: 18947767
sylong had the right answer but duncan had the better explanation :  points split.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now