Linux - Zip / Unzip

Bash Liste Des Attaques Ovh


The zip manager in Linux


  • take advantage of redundancy between files.

split archives:

  • storing a large archive on multiple removable media.
  • split big file ?

How to


List the content

unzip -l


/usr/bin/unzip -l
  Length     Date   Time    Name
 --------    ----   ----    ----
        0  04-12-17 08:55   25797429/
    68000  04-12-17 08:55   25797429/
318682896  04-12-17 08:30   25797429/
545626254  04-12-17 08:55   25797429/
456596466  04-12-17 08:33   25797429/
182417792  04-12-17 08:55   25797429/
   114984  04-15-17 20:38   25797429/README.html
1052740398  04-12-17 08:55   25797429/
 91360658  04-12-17 08:55   25797429/
1036787935  04-12-17 08:36   25797429/
 --------                   -------
3684395383                   10 files

Unzip all zip files of a directory

/usr/bin/unzip \*.zip
  inflating: 13952743/files/common/script_handlers/
  creating:  13952743/files/clone/
  creating:  13952743/files/clone/provision/
  inflating: 13952743/files/clone/provision/adf_t2p_registration.xml
  inflating: 13952743/files/clone/provision/adf-t2p-cloner.jar
  inflating: 13952743/README.txt

9 archives were successfully processed.

Unzip only a sub-directory of the zip file

The root directory is still preserved 'my/sub/folder', you need to move it. The -j option flatten the whole structure and is not what you want

unzip 'my/sub/folder' -d /dest/dir

Zip a directory recursively

/usr/bin/zip -r ./targetDir/*

in the background

nohup zip -r directory/* &

You can monitor it with the command:


or with this until statement (You need to change the pid)

while kill -0 $pid 2> /dev/null; do
    count=$(( $count + 1 ))
    echo "${count} - Process is running"
    sleep 10
echo "${count} - Process has exited"

Zip a file

zip /myFile

Unzip in a target directory

unzip -d myTargetDirectory

Zip only a subset of a files

Under Unix, the option -@ file list can be used to powerful effect in conjunction with the find command.

For example, to archive all the C source files in the current directory and its subdirectories:

find . -name "*.[ch]" -print | zip source -@

Zip a subset of files selected by attributes (date/name…)

With the find

Example: zip all files modified the last 7 days

find . -mtime -7  -type f -print | zip -@


  • . means start the search from the current directory
  • -mtime -7 means select all files modified from 7 days ago.
  • -@ tells zip to read files from the input


unzip: cannot find or open

You may get this kind of message:

unzip:  cannot find or open ./, ./ or ./

Just try to use another unzip application.



Discover More
Bash Liste Des Attaques Ovh
Bash - Directory

directory management with bash. See To get the space by directory, you can use the du command. It summarize disk usage of each FILE, recursively for directories. With a redirection, you...

Share this page:
Follow us:
Task Runner