Three usefull shell tricks for creating zips

There tricks are usefull because you often need to zip only a certain type of files or all the files in a directory.

Watch Free Movies

In this article I will also prove the power of the asterisk (*) wildcard:

I have this files:

$ ls
eight five.txt four.txt nine one.exe seven six.txt three.exe two.exe

Trick one: Adding to archive only the .exe files:

$ zip myexe *.exe
adding: one.exe (stored 0%)
adding: three.exe (stored 0%)
adding: two.exe (stored 0%)

Trick two: Adding to archive all the files with extensions:

$ zip extonly *.*
adding: five.txt (stored 0%)
adding: four.txt (stored 0%)
adding: myexe.zip (stored 0%)
adding: one.exe (stored 0%)
adding: six.txt (stored 0%)
adding: three.exe (stored 0%)
adding: two.exe (stored 0%)

Trick three: Adding to archive all the files from the dir:

$ zip all *
adding: eight (stored 0%)
adding: extonly.zip (stored 0%)
adding: five.txt (stored 0%)
adding: four.txt (stored 0%)
adding: myexe.zip (stored 0%)
adding: nine (stored 0%)
adding: one.exe (stored 0%)
adding: seven (stored 0%)
adding: six.txt (stored 0%)
adding: three.exe (stored 0%)
adding: two.exe (stored 0%)

Read more about using wildcards here.

Scroll to Top