Tar multiple folder to multiple files to another directory and delete original folder
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.