LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-31-2006, 03:18 PM   #1
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Rep: Reputation: 30
Unable to create a tar file from spanning a directory tree?


I need to create a tar file that contains a number of .res files, and I need the tarball to contain the path to these .res files as well. The problem is that I want to create the tarball from a 3-deep directory tree.

- The base directory contains 24 directories
- Each of those 24 directories contain 33 directories
- Inside each of those 24*33 directories is a .res file that I want to capture in my tarball (there are also many other files that I do not wish to capture)

So I cd to the base directory and type:

Code:
tar -cvf my_results.tar */*/*.res
But I get some error message saying that the tree is too deep or something (this is on my machine at work...I cant seem to reproduce the same error on my own machine at home). Has anyone encountered this problem and know of an efficient way around it? (I really do need to have just a single tarball with these files, not multiple tarballs). Thanks
 
Old 10-31-2006, 03:59 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
*/*/* is not a good approach, not even sure if that will work.

Use find with the exec option, it also has a max depth option.

cd <directory>
find . -type f -name *.res -maxdepth 3 -exec tar cvf my_results.tar {} \;

Exclude the -exec portion off to have it print off the findings to verify before tarballing the files. you could also just do a find without the exec and pipe it to xargs to tarball it.

find . -type f -name *.res -maxdepth 3 | xargs tar cvf my_results.tar
 
Old 11-01-2006, 10:15 AM   #3
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Original Poster
Rep: Reputation: 30
Awesome, thanks that did the trick! I need to find the time to get more intimate with my shell one of these days.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to use tar -xzvf with a abc.tar.gz file kakultech Linux - Software 6 11-08-2010 11:03 AM
What is spanning tree protocol inaki Linux - Networking 3 01-02-2006 02:49 PM
STP (Spanning Tree) on Bridge slacky Linux - Networking 5 12-06-2005 09:15 AM
Spanning Tree query balajee Linux - Networking 2 09-29-2005 03:40 AM
Spanning tree (for bridge)????? RWild Linux - Networking 8 02-21-2003 12:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration