We demonstrated how to extract tar files to a specific or alternative directory under Linux in one of our many articles regarding the tar command. This short tutorial will show you how to extract/unzip.zip archive files on Linux to a specific or alternative directory.
Zip is a cross-platform file packaging and compression software for Unix-like systems, such as Linux and Windows OS, as well as a variety of other operating systems. The “zip” format is a popular archiving file format for Windows PCs, and it allows you to choose between compression levels of 1 and 9 as an option.
In Linux, you can make a zip archive file.
You can use a command similar to the one below to create a.zip (compressed and packaged) file from the command line. The -r argument enables recursive file directory structure reading.
$ zip -r tecmint_files.zip tecmint_files
You can use the unzip command to unzip the tecmint files.zip archive file you just prepared above.
$ unzip tecmint_files.zip
The files will be extracted into the current working directory using the command above. What if you wish to unzip the files into a certain or other directory? This is covered in the next section.
Extract the Zip File to a Specific or Alternative Directory
Include the -d unzip command flag to extract/unzip.zip archive files to a specific or different directory from the command line, as illustrated below. To explain this, we’ll use the same example as before.
This will extract the contents of the.zip file to the /tmp directory:
$ mkdir -p /tmp/unziped
$ unzip tecmint_files.zip -d /tmp/unziped
$ ls -l /tmp/unziped/
Read the man pages for the zip and unzip commands for further information on how to use them.
$ man zip
$ man unzip
What do you think?