In one of our several articles about the tar command, we showed you how to extract tar files to a specific or different directory in Linux. This short guide explains you how to extract/unzip .zip archive files to specific or different directory in Linux.
Zip is a simple, cross-platform file packaging and compression utility for Unix-like systems including Linux and Windows OS; plus many other operating systems. The “zip” format is a common archiving file format used on Windows PC’s and most importantly, it enables you to specify the compression level between 1 and 9 as an option.
Read Also: 5 Best Command Line Archive Tools for Linux
Create Zip Archive File in Linux
To create a .zip (packaged and compressed) file from the command line, you can run a similar command as the one below, The -r flag enables recursive reading of files directory structure.
$ zip -r tecmint_files.zip tecmint_files

Create Zip File in Linux
To unzip the tecmint_files.zip archive file you have just created above, you can run the unzip command as follows.
$ unzip tecmint_files.zip
The above command will extract the files into the current working directory. What if you want to send the unziped files into a specific or different directory – you can learn this in next section.
Extract Zip File to Specific or Different Directory
To extract/unzip .zip archive files to specific or different directory from the command line, include the -d unzip command flag as shown below. We will use the same example above to demonstrate this.
This will extract the .zip file content into the /tmp directory:
$ mkdir -p /tmp/unziped
$ unzip tecmint_files.zip -d /tmp/unziped
$ ls -l /tmp/unziped/

Extract Zip Files to Specific Directory
For more usage information, read zip and unzip command man pages.
$ man zip
$ man unzip
You may also like to read following related articles.
- How to Archive/Compress Files & Directories in Linux
- How to Open, Extract and Create RAR Files in Linux
- Peazip – A Portable File Manager and Archive Tool for Linux
- Dtrx – An Intelligent Archive Extraction (tar, zip, cpio, rpm, deb, rar) Tool for Linux
In this short article, we have explained how to extract/unzip .zip archive files to specific or different directory in Linux. You can add your thoughts to this article via the feedback form below.
',
enableHover: false,
enableTracking: true,
buttons: { twitter: {via: 'tecmint'}},
click: function(api, options){
api.simulateClick();
api.openPopup('twitter');
}
});
jQuery('#facebook').sharrre({
share: {
facebook: true
},
template: '
{total}
',
enableHover: false,
enableTracking: true,
click: function(api, options){
api.simulateClick();
api.openPopup('facebook');
}
});
jQuery('#googleplus').sharrre({
share: {
googlePlus: true
},
template: '
{total}
',
enableHover: false,
enableTracking: true,
urlCurl: 'https://www.tecmint.com/wp-content/themes/tecmint/js/sharrre.php',
click: function(api, options){
api.simulateClick();
api.openPopup('googlePlus');
}
});
jQuery('#linkedin').sharrre({
share: {
linkedin: true
},
template: '
{total}
',
enableHover: false,
enableTracking: true,
buttons: {
linkedin: {
description: 'How to Create and Extract Zip Files to Specific Directory in Linux',media: '/uploads/2017/07/Unzip-Extract-Zip-Files-to-Specific-Directory.png' }
},
click: function(api, options){
api.simulateClick();
api.openPopup('linkedin');
}
});
// Scrollable sharrre bar, contributed by Erik Frye. Awesome!
var shareContainer = jQuery(".sharrre-container"),
header = jQuery('#header'),
postEntry = jQuery('.entry'),
$window = jQuery(window),
distanceFromTop = 20,
startSharePosition = shareContainer.offset(),
contentBottom = postEntry.offset().top + postEntry.outerHeight(),
topOfTemplate = header.offset().top;
getTopSpacing();
shareScroll = function(){
if($window.width() > 719){
var scrollTop = $window.scrollTop() + topOfTemplate,
stopLocation = contentBottom - (shareContainer.outerHeight() + topSpacing);
if(scrollTop > stopLocation){
shareContainer.offset({top: contentBottom - shareContainer.outerHeight(),left: startSharePosition.left});
}
else if(scrollTop >= postEntry.offset().top-topSpacing){
shareContainer.offset({top: scrollTop + topSpacing, left: startSharePosition.left});
}else if(scrollTop < startSharePosition.top+(topSpacing-1)){
shareContainer.offset({top: startSharePosition.top,left:startSharePosition.left});
}
}
},
shareMove = function(){
startSharePosition = shareContainer.offset();
contentBottom = postEntry.offset().top + postEntry.outerHeight();
topOfTemplate = header.offset().top;
getTopSpacing();
};
/* As new images load the page content body gets longer. The bottom of the content area needs to be adjusted in case images are still loading. */
setTimeout(function() {
contentBottom = postEntry.offset().top + postEntry.outerHeight();
}, 2000);
if (window.addEventListener) {
window.addEventListener('scroll', shareScroll, false);
window.addEventListener('resize', shareMove, false);
} else if (window.attachEvent) {
window.attachEvent('onscroll', shareScroll);
window.attachEvent('onresize', shareMove);
}
function getTopSpacing(){
if($window.width() > 1024)
topSpacing = distanceFromTop + jQuery('.nav-wrap').outerHeight();
else
topSpacing = distanceFromTop;
}
});
Source:
tecmint.com