82
18
How do I make a .zip file that contains every file AND every folder in the directory?
82
18
How do I make a .zip file that contains every file AND every folder in the directory?
126
zip -r foo.zip dir_path
The -r means recursive and tells it to go through all of the sub folders. You don't really need the .zip
on the filename (foo.zip
) as it will create this anyway. – user2924019 – 2016-07-21T07:50:31.723
@user2924019's comment that you dont need to specify the zip name is not true in CentOS7. – killjoy – 2018-01-21T16:14:07.473
CentOS7 is exactly where I tested this. – user2924019 – 2018-01-23T15:51:08.577
3Well, we've come to what is known as a Mexican standoff, now haven't we? – seizethecarp – 2018-03-02T21:51:13.340
16
Try:
zip -r filename.zip /path/to/folder
Note - this will go recursively, i.e. it will zip all folders and all subfolders of the given folder.
5
Use the -r
option. From zip(1):
-rTravel the directory structure recursively; for example:
zip -r foo foo
The name of the zip file comes first. "Recursively" means that the zip file will include subfolders of the given folder, the subfolders of those folders, and so on.
Where the .zip file goes after zipping? – Siraj Alam – 2017-07-27T17:56:54.937
To the path specified. foo
in this example. – Mathias Lykkegaard Lorenzen – 2020-01-03T11:56:05.330
3
If you are bound to a zip, I'd use:
zip -r zipfilename directoryPath
The -r
is the key, but you can find all the options here.
1
I use 'tar': tar -zcvf archive.tar.gz directory/ http://unix.stackexchange.com/questions/93139/can-i-zip-an-entire-folder-using-gzip
– njuhgn – 2014-10-20T05:21:10.817Does it need to be a .zip or are you just after a compressed file? – None – 2010-11-23T03:41:13.470