0

Is it possible to zip a folder while copying it? I want to copy a folder and then zip it, but this implies that I need for a while twice the space in my /mnt path, right?

/bin/cp -r /mnt/myfolder /mnt/new_folder ; tar -zcvf /mnt/new_folder.zip /mnt/new_folder 

Is it possible to avoid this?

Thanks

  • 1
    tar != zip Imagine how surprised the ZIP user will be when they discover that the .zip file you sent them actually isn't a .zip file at all. You'd be well-advised to use a .tgz or .tar.gz extension instead. – Jim L. Aug 28 '19 at 19:31
  • Thanks! I tried to open it with 7-Zip without problem, but I will fix the extension anyway! – DDBE Aug 29 '19 at 7:53
3

Instead of copying the folder you could just zip it by using tar specifying the path of the target file: you could try

tar -zcvf /mnt/new_folder.zip /mnt/myfolder

the tar program does not replace your original folder...

| improve this answer | |

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.