2

I want to create a compressed tape archive of a folder in a directory (we'll call it A) that I have put model output into. I want to be able to also move this .tar.gz file to another directory (we'll call it B). Is it possible to create this tarball from directory B.

The reason I ask, is because I am running out of disk space in A, and I was under the impression that in order to create the tarball, it would require more space than I currently have in A.

If this is possible, can you give me an example of how the command would look? I hope this makes enough sense. Thanks!

  • Can't you just do cd /path/to/dirA ; tar cvfz /path/to/dirB/backup.tar.gz . ? That'll create the tarball directly in dirB and doesn't require any extra space in dirA. – Stephen Harris Aug 24 '16 at 19:09
  • Yes, this is what I was looking for. Thanks! – Ali Koleiny Aug 25 '16 at 20:44
0

Despite the best efforts of some to compress things in place, tar can indeed create a file on some other filesystem (or can pipe the tarball to some other system via SSH, if the local machine is really short on the disk space).

cd A
tar cvzf /path/to/B/archive.tgz a_folder
tar cvz a_filter | ssh somehost '...'

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.