zip command in Linux with Examples

zip command in Linux means Package and compress (archive) files.

zip command in Linux with Examples

Syntax

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

On the man page, the describes 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 a simple command in Linux. It is the most popular in use terminal Linux package and compress (archive) files. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. 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 *

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