Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I zip a file and save it in another directory using the command line? I have no space left in directory (100% full).

share|improve this question
    
You don't do that on PuTTY. PuTTY is just the tool you use to access the "other" computer; so it is not a PuTTY question, but (maybe) a shell one. –  glglgl Jul 6 at 11:13

2 Answers 2

zip -r  /path/to/save/destination_folder.zip /path/to/folder
  • /path/to/folder - path to your source folder

  • /path/to/save/destination_folder.zip - path to destination zip-file

  • r - recurse into directories

Also you can just type zip in putty command prompt to get help information

Please, notice I wrote information for *nix systems. For Win it could be differ.

share|improve this answer
1  
One line command answers are often not as helpful as if the answerer were to provide a little more detail. You should consider expanding your answer to include details such as: what package provides the zip command, what the -r flag actually does, and perhaps some excerpts from documentation that supports your answer. –  HalosGhost Jul 6 at 3:11

Quickly looking at the man pages for tar, we can set the output file with -f

I usually use something of the form:

tar -a -cf filename.tar.bz2 input_fname.txt

Then you can specify your filepath as part of your filename to output. For example /mnt/drive_1/output.tar.bz2 or ../../output.tgz would work as a filename. Then you would end up with your compressed file at that place.

Arguments:

  • a: auto compress: Uses your given file type to figure out what to do.
  • c: compress: Tells it to compress instead of decompressing
  • f: set a file name: allows you to specify your file and file path. You can also give relative path names as well.

I'm hoping that tar compression just puts everything at the output file and doesn't do anything in your directory. Try it and see if it works though.

share|improve this answer
    
While I gave examples with tar.bz2 and tgz, it will work with the zip extension as well. –  Evan Jul 6 at 2:39
    
'c' is not the compression option, it is the "create" option. zip is not supported by GNU tar. zip is both an archiver and a compression format. –  GregS Jul 6 at 16:43
    
I don't know if we have different versions of tar, but in my man pages, under the -a, --auto-compress option, it says that it ignore things like -j if it doesn't work with the file extension. In my man pages for creating a new archive with the zip format: "tar -a -cf archive.zip source.c source.h creates a new archive with zip format," along with some other features. You are right that it is to create an archive and not compress one though. –  Evan Jul 6 at 16:53
    
I was going by GNU tar –  GregS Jul 6 at 16:56
    
When I run "tar -a -cf archive.zip source.c source.h" with GNU tar I get an uncompressed tar archive, not a zip archive. –  GregS Jul 6 at 17:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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