zip command in Linux with Examples

zip command means Package and compress (archive) files.

Syntax

zip [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [–longoption …] [-b path] [-n suffixes] [-t date] [-tt date] [zipfile [file …]] [-xi list]

In man page the describe it

  • zip – package and compress (archive) files.
  • man zip – More details information about zip command.

zip command in Linux with Examples

$ zip devopsroles.zip devopsroles.txt

Add new files to the existing zip file

[vagrant@DevopsRoles ~]$ ll
 total 4
 drwxrwxr-x. 3 vagrant vagrant  20 Oct  1 06:51 DevopsRoles
 -rw-rw-r--. 1 vagrant vagrant 638 Oct  1 06:46 Devops.zip
 [vagrant@DevopsRoles ~]$ touch newfile.txt
 [vagrant@DevopsRoles ~]$ unzip -l Devops.zip 
 Archive:  Devops.zip
   Length      Date    Time    Name
 ---------  ---------- -----   ----
         0  10-01-2019 06:45   Devops/
         0  10-01-2019 06:45   Devops/DevopsRoles/
         0  10-01-2019 06:45   Devops/huupv.csv
         0  10-01-2019 06:45   Devops/xxx
 ---------                     -------
         0                     4 files
 [vagrant@DevopsRoles ~]$ zip -u Devops.zip newfile.txt 
   adding: newfile.txt (stored 0%)
 [vagrant@DevopsRoles ~]$ unzip -l Devops.zip 
 Archive:  Devops.zip
   Length      Date    Time    Name
 ---------  ---------- -----   ----
         0  10-01-2019 06:45   Devops/
         0  10-01-2019 06:45   Devops/DevopsRoles/
         0  10-01-2019 06:45   Devops/huupv.csv
         0  10-01-2019 06:45   Devops/xxx
         0  10-01-2019 06:56   newfile.txt
 ---------                     -------
         0                     5 files

Conclusion

zip command is the simple the command in Linux. It is the most popular in use terminal Linux package and compress (archive) files.

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.