7zip destination folder -o
I have wondered a long time how to do this and read already many manuals but dont get this to work. I want to zip with 7zip a folder to specific destination. There is in manual a guide to use -o{folder} but how does it really work?
Example:
7z a -t7z serverx /home/example/folder -o/home/backups/folder1
How to use that -o? Destination folder exists.
Solution 1:
From man 7z
:
-o{Directory}
Set Output directory
It is basically the destination directory for extracting the archive. All the extracted files will be saved in the given directory. This option won't be used in case of creating the archive.
Here is an example:
$ 7z a -t7z check.7z file.txt -ofoo/
Creating archive check.7z
Compressing file.txt
Everything is Ok
$ ls
check.7z file.txt foo
$ 7z x -t7z check.7z -ofoo/
Processing archive: check.7z
Extracting file.txt
Everything is Ok
Size: 180
Compressed: 221
foo$ ls
file.txt
Solution 2:
To extracts into a directory, you must remove any spaces after the -o
for example,
Extract zip file into a new or existing directory dir1
:
7z x file.zip -o./dir1
Compress directory dir1
to a new zip file:
7z a newfile.zip ./dir1