Unzip a specific folder of a compressed file & exclude some folders from extraction

You have a huge zip file with thousands of files in it. You want to extract a specific folder inside the zip, but you also want to exclude some files and folders from the extraction.

Assume that compressed_file.zip file contains the following folder and file structure:

You can check the zip content by unzip -l compressed_file.zip command.

  • path/
  • path/to/
  • path/to/extract/
  • path/to/extract/file1.txt
  • path/to/exclude
  • path/to/exclude/file2.txt

You want to extract just path/to/extract/ folder, but want to exclude any folders under exclude folder.

unzip compressed_file.zip path/to/extract/* -x *exclude*

When you run the command above, you will only get the following content.

  • path/
  • path/to/
  • path/to/extract/
  • path/to/extract/file1.txt

With the command above, only path/to/extract folders exist. Exclude folders do not exist.

By the way, the performance is lighting fast:) Enjoy!

About these ads
Tagged

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 833 other followers

%d bloggers like this: