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?


  • 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.
    Commented Aug 28, 2019 at 19:31
  • Thanks! I tried to open it with 7-Zip without problem, but I will fix the extension anyway!
    – DDBE
    Commented Aug 29, 2019 at 7:53

1 Answer 1


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...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .