UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old January 19th, 2005, 09:33 AM
smiles78 smiles78 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 46 smiles78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 33 sec
Reputation Power: 5
Question Tar / scripting quesiton - tar-ing recursively?

I'm not sure what my title should be exactly.
I'm trying to tar up entire directory but specify which files to take because some files need to be ignored. The files that need to be ignore are "hidden" files that start with ".".

The directory , say named MainPages contain files as well as directories. Then under the next level directory, say named images contain files and more directories.

MainPages/
.randomhiddenfile
index.txt
startup.java
images/
.imagehiddenfile
logo.jpg
people/
animals/
And so on....

I can't remove the hidden files as they are used for other purposes elsewhere. I do tar cvf test.tar MainPages/[a-zA-z]* and that will work to not include .randomhiddenfile but will still include the files under images.

I can't hard code this because the names of the directories can change so I need to make it recursive, like for each directory under main do this sort of thing...

Reply With Quote
  #2  
Old January 19th, 2005, 10:56 AM
vgersh99 vgersh99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 47 vgersh99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 5 h 36 m 43 sec
Reputation Power: 4
Send a message via AIM to vgersh99 Send a message via MSN to vgersh99 Send a message via Yahoo to vgersh99
how 'bout:

tar cvf myTar.tar $(find MainPages ! -name '.*')

or

find MainPages ! -name '.*' -type f | xargs tar cvf myTar.tar

Reply With Quote
  #3  
Old January 19th, 2005, 12:21 PM
smiles78 smiles78 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 46 smiles78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 33 sec
Reputation Power: 5
Quote:
Originally Posted by vgersh99
how 'bout:

tar cvf myTar.tar $(find MainPages ! -name '.*')

or

find MainPages ! -name '.*' -type f | xargs tar cvf myTar.tar



The second one worked, but the first one didn't.

Also, I was looking into tar and there is a X option to exclude files but I can't get it to work no matter what. Does someone have a working example? I need to list multiple files to exclude. No matter what I do it always includes them.

Reply With Quote
  #4  
Old January 19th, 2005, 12:48 PM
vgersh99 vgersh99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 47 vgersh99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 Days 5 h 36 m 43 sec
Reputation Power: 4
Send a message via AIM to vgersh99 Send a message via MSN to vgersh99 Send a message via Yahoo to vgersh99
Quote:
Originally Posted by smiles78
The second one worked, but the first one didn't.



if you ARE not using ksh/bash, try:

tar cvf myTar.tar `find MainPages ! -name '.*'`

Quote:
Originally Posted by smiles78
Also, I was looking into tar and there is a X option to exclude files but I can't get it to work no matter what. Does someone have a working example? I need to list multiple files to exclude. No matter what I do it always includes them.


tar -cXvf tarr.X tarr.tar tarr

tarr.X - file containg paths to files to be EXCLUDED
tarr.tar - the tar file to be created
tar - directory to be tar-ed

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Tar / scripting quesiton - tar-ing recursively?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway