

Unzip command extracts list files from the ZIP archive on Unix systems. Where folder/file_1 is replaced whereas folder/file_3 is new.So, folder.zip now contains folder/file_1, folder/file_2, and folder/file_3, along folder/file_2 from before that are unchanged. So, if before a zip command will execute, folder.zip has: when the same name of zip archive is found then it will update it.Įxample: If folder/file_1 and folder/file_2 is contained in folder.zip and the directory folder contains the files folder/file_1 and folder/file_3. The zip file is a new or existing zip archive and fileDir/fileList is the path occasionally including wildcards.

Web development, programming languages, Software testing & others

Output -rw-r-r- 1 immukul staff 2201512 Jul 14 09:19 zipContent.Start Your Free Software Development Course In the above command, we can notice the -j option which stands for “junk the path”, that will help you in ignoring the directory structure. In order to make sure that you don’t get a directory structure mimicking the files, you can make use of the command shown below Command zip -j zipContent d1/file.txt d2/2.txt d2/3.txt Output -rw-r-r- 1 immukul staff 661 Jul 14 09:02 sample.txt You can also unzip the zip file to get the files back with the help of the command shown below − Command unzip file.zip Command zip file.zip sample.txt Output -rw-r-r- 1 immukul staff 661 Jul 14 09:00 file.zip Example 2 Syntax zip zipfile files Example 1Ĭonsider a case where you want to convert a single file into a zip file, then the command shown below will allow you to do just the same. The compression of files actually involves one or more compressed filed and it compresses them into a single zip archive, along with some information about those files. In simple terms, it is used to reduce the size of files with the help of compression and sometimes also used as a file package facility.

The zip command that Linux provides us with allows us to specify a compression level with a number prefixed with dash and that number is usually in between 0 and 9. In order to be able to zip file and ignore directory structure that gets created with it, we first must understand what the zip command on Linux actually means and how we can make use of it.
