Linux unzip Command Example

Blogs ❯❯ Linux

Image could not load

Image on pixabay

what is zip ?

ZIP एक archive file format है जो lossless data compression
support करता है। lossless data compression का मतलब है बिना कोई data को loss किये perfectly कम size में compress करना। ZIP file format कई compression algorithms allow / use करती है , जिनमे DEFLATE सबसे common है।

Linux Install unzip

Linux में unzip command का use किसी zip file को extract करने के लिए किया जाता है। अगर आपके system पर unzip installed नहीं है , तो नीचे दी गयी command को run करके पहले unzip install कर लें।

$ sudo apt update
$ sudo apt install unzip

Linux unzip options

बैसे तो unzip command में कई options हैं जिन्हे आप unzip --help command run करके देख सकते हैं।

$ unzip --help

Linux unzip Examples

Example के लिए हमने पिछले topic (Linux zip Command) में एक index.zip file create की थी , उसी zip files को different - different तरीके से वापस unzip करने की कोशिश करेंगे।

Linux unzip file
$ unzip zip_filename

जब आप किसी zip file को unzip करेंगे तो जिस structure में zip file में content होगा उसी structure में extract हो जायगा।

$ unzip index.zip 
Archive:  index.zip
  inflating: python.html
   creating: dir1/
  inflating: dir1/blogs

Output में आप देख सकते हैं कि index.zip file से कौन कौन सी files unzip हुई है। बाकी listing के लिए आप ls Command या tree Command का use कर सकते हैं।

$ tree
.
├── dir1
│   └── blogs
├── index.zip
└── python.html

1 directory, 3 files

unzip in a new Folder

zip file content को किसी new folder में extract करने के लिए -d option का use कर सकते हैं। pass की गयी directory अगर नहीं बनी तो new directory create हो जाएगी और अगर बनी हुई है तो उसमे content extract हो जायगा।

$ unzip -d zip_dir index.zip 
Archive:  index.zip
  inflating: zip_dir/python.html
   creating: zip_dir/dir1/
  inflating: zip_dir/dir1/blogs

overwrite files

बैसे तो इसकी need कम ही पड़ती है लेकिन फिर भी आप extract किये गए content को फिर से overwrite करना चाहते हैं तो , आपको -o option का use करना पड़ेगा।

$ unzip -o index.zip 

Exclude files while extracting a ZIP file

extract करते समय आप ये भी define कर सकते हैं कि zip file से कौन सी files extract हो। unzip करते समय files को exclude करने के लिए -x option का use किया जाता है।

$ unzip -x index.zip python.html

यह option बहुत important है , जिसे आप different तरीके से use कर सकते हैं।

For example

unzip -x zip_filename file1 file2     // exclude multiple files
unzip -x zip_filename *.html     // exclude only html files, you can use other extensions also.
unzip -x zip_filename *txt     // exclude files that ends with txt name
.
and so on
Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook