?
Solved

Unix / Linux Command question

Posted on 2007-04-08
4
Medium Priority
?
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 800 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 35

Assisted Solution

by:Duncan Roe
Duncan Roe earned 200 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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

719 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