The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep'ing for specific directories, and using the output to move files JayC89 Shell Programming and Scripting 1 12-06-2008 03:37 AM
need to move find results pimentelgg Shell Programming and Scripting 9 12-20-2007 06:00 PM
moving directories to new directories on multiple servers mackdaddy07 Shell Programming and Scripting 0 04-06-2007 12:30 PM
Different results from awk, sed, tr in different directories??? james_falco HP-UX 2 02-23-2007 02:02 AM
Compare directories then move similar ones tgibson2 UNIX for Dummies Questions & Answers 2 02-11-2006 07:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-10-2009
jccbin jccbin is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 5
tar, zip multiple separate directories and move the results to another volume

TIA,

I'm using FreeBSD 6

I have a series of Directories (A,B,C,...Z). Each directory has files and other directories within it.

I want to compress the contents of each top directory into a single file so that I get an archive of each directory (for example, A.gzip) AND and want to move that compressed file to another volume on the system.

I have managed to be able to gzip the contents of each directory, but end up with a complete directory structure full of .gzips.

Looking on here I see that tar appears to be able to create the single-file archives I want, but I cannot tell if tar will compress and combine the files AND put the finished results on the other volume.

Ideas? Thanks again,

johnC
  #2 (permalink)  
Old 03-10-2009
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,585
tar wont compress but will create an archive, you just have to gzip it after and you will find yourself with a <my_archive>.tar.gzip file
easy no?
  #3 (permalink)  
Old 03-10-2009
jccbin jccbin is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 5
Thanks, but how do I get all that into one command?

"Hi there, tar! Will you please make an archive of Volume_Source/Directory_A, then gzip it for me and save the results on Volume_Target/?"

would this work:


Code:
tar -czf /Volumes/Volume_Target/A.tar.gz /Volumes/Volume_Source/Directory_A

?
  #4 (permalink)  
Old 03-11-2009
frozentin frozentin is offline
Registered User
  
 

Join Date: May 2008
Location: Vienna, VA + Bombay, India
Posts: 109
Does your implementation of "tar" have a -z flag? If yes, then the above should work.
  #5 (permalink)  
Old 03-11-2009
jccbin jccbin is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 5
Thanks for the confirmation. I tried it when I got home last night and it did work. Now I just need to find a way to automate this command to run on each directory individually. I mean, tar and gzip Directory A to Volume B, then tar and gzip directory B to Volume B, then tar and gzip Directory C to Volume B and so on.... Is this a shell script thing? I have tried to understand the various options under tar or gzip but I don't see that sort of intelligence in the options....

TIA,

johnC
  #6 (permalink)  
Old 03-11-2009
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,585
Yes this is a shell script thing...
You will need a loop:

Code:
something like
for i in A B C D...
do
   cd  $i
   tar -c ...
done

Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0