DEV Community

Cover image for Living in the Shell #7; zip
Babak K. Shandiz
Babak K. Shandiz

Posted on • Originally published at babakks.github.io on

Living in the Shell #7; zip

zip 🗜️

Creates ZIP archives.

Test archive integrity -T

zip -T x.zip
Enter fullscreen mode Exit fullscreen mode

Create/update zip archive (add/update file)

zip x.zip ~/.bashrc ~/.profile
Enter fullscreen mode Exit fullscreen mode

Creates x.zip archive file (if not exist) and adds .bashrc and .profile to it.

Add directory and its content -r

zip -r x.zip ~/Documents
Enter fullscreen mode Exit fullscreen mode

Without -r nothing is added.

Add all names except directories -D

zip -D x.zip ~/*
Enter fullscreen mode Exit fullscreen mode

Set password while add/update files -P

zip -P my-password x.zip file-to-add-or-update.txt
Enter fullscreen mode Exit fullscreen mode

Store-only mode (fast, without compression) -0

zip -0 x.zip ~/Pictures
Enter fullscreen mode Exit fullscreen mode

Fast compression mode (fast, low compression) -1

zip -1 x.zip ~/Pictures
Enter fullscreen mode Exit fullscreen mode

Ultimate compression mode (slow, maximum compression) -9

zip -9 x.zip ~/Pictures
Enter fullscreen mode Exit fullscreen mode

Delete file from archive -d

zip -d x.zip .bashrc
Enter fullscreen mode Exit fullscreen mode

Top comments (0)