Currently, I use this command to make tar.gz archives:

sudo tar -zcpvf archive.tar.gz directory1 directory2 directory3

Is there a way to compress multiple archives like above, but instead of compressing regular folders, have tar make sub tar.gz files? So, for example, I want to be able to make archive.tar.gz and see it contain directory1.tar.gz, directory2.tar.gz and directory3.tar.gz on the first level folders only.

I know I can compress directory1, directory2, and directory3 individually and then add them to another archive, but is there a way to do what I'm asking with one command?


No other way than compressing directory1, directory2 and directory3 beforehand, sorry.

| improve this answer | |
  • 1
    Of course, you can build a command to do the whole zipping as a one-liner. – Oct Feb 16 '16 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.