LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-30-2016, 11:04 AM   #1
zeroize
LQ Newbie
 
Registered: Mar 2016
Posts: 2

Rep: Reputation: Disabled
Tar multiple folder to multiple files to another directory and delete original folder


Hi People, I'm using Suse Linux and need help on the shell script

my scenario is as below. under my main folder "root" I have sub folder Folder A, B and C, and inside each subfolder comes with another sub folder named F1, F2 F3 recpectively.

/root/A/F1
/root/A/F2
/root/A/F3

/root/B/F1
/root/B/F2
/root/B/F3

/root/C/F1
/root/C/F2
/root/C/F3

I need to zip all the folder individually to another location(/zipped/) with original parent folder and name like ../A/F1.tar.gz, ../A/F2.tar.gz, ../B/F1.tar.gz, ../B/F2.tar.gz etc. Then delete the original folder.

Can anyone help me with the script?

Last edited by zeroize; 03-30-2016 at 11:10 AM.
 
Old 03-30-2016, 11:13 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,026

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
please post your command and any error message between code tags and perhaps someone will be able to help you debug.
 
Old 03-30-2016, 11:17 AM   #3
zeroize
LQ Newbie
 
Registered: Mar 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
please post your command and any error message between code tags and perhaps someone will be able to help you debug.
I have no problem using single tar commands for single folder and single output, i need help on the scripting for multiple folders and I'm weak in this.
 
Old 03-30-2016, 11:21 AM   #4
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 2,061

Rep: Reputation: Disabled
something like google "tar multiple directories"
rm --help
to get the rest of it
then
Code:
#!/bin/bash

place command line arguments in here
 
Old 03-30-2016, 09:07 PM   #5
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
slightly off topic but, so tar archives recursively by default

Quote:
something like google "tar multiple directories"
result from linuxquestions to that effect.

but does it just tar that directory or will it accept /*

Fred.

I suppose I could just try it!
 
Old 03-30-2016, 09:10 PM   #6
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 2,061

Rep: Reputation: Disabled
Quote:
Originally Posted by Fred Caro View Post
slightly off topic but, so tar archives recursively by default



result from linuxquestions to that effect.

but does it just tar that directory or will it accept /*

Fred.

I suppose I could just try it!
I've personally have never had to do this so I do not know. but I'd go with your gut feeling that made you say... "I suppose I could just try it!" feeling, and that is the best way to learn... set up a few test fake directories with crap files in it then zip them all together then remove the originals via a script, or go command line first.

if you say tar -c /* think what they might equate to...

MOD: you're not OP oops

using my suggestion of search words I found this really excellent link in how to set yourself of a "test bed" to try this with. go to answer #2 to see it.

http://stackoverflow.com/questions/2...-parent-folder

Last edited by BW-userx; 03-30-2016 at 09:19 PM.
 
Old 03-31-2016, 08:36 PM   #7
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
BW-userx
that is cheating using '-C'
but I assume tar crosses directories, at least those that are below them by a default operation.
Man pages are a wealth of info but rather terse and don't mean much to the uninitiated or when you try to build a picture, more examples would help. Winge, winge.

Fred.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
make multiple folder on samba linux & each folder can be access each person only Aneesh.T .S Linux - Server 1 01-31-2013 07:01 PM
Unzip multiple zip files, each to separate folder smart_sagittari Linux - Newbie 3 03-21-2012 09:41 AM
how to compress ~130GB folder and erase original files at the same time arshadul Linux - Newbie 3 04-20-2009 07:48 PM
Package Folder into Multiple tar files??? mefman Linux - Newbie 9 04-01-2008 06:38 AM
How do I decompress and desarchive multiple .tar.gz files to a single directory? Baldorg Linux - Software 7 11-27-2003 01:42 PM


All times are GMT -5. The time now is 10:40 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration