dwlamb
dwlamb

Reputation: 925

zip a list of files at command-line linux

If I have a list of files I want to zip, how can I pass the list to zip?

cookbook/application/views/index.php
cookbook/application/controller/index.php
cookbook/js/index.js
....
cookbook/css/index.css

To do the above list one by one at the command-line would be like zip -r my.zip cookbook/css/index.css, where my.zip is in the same root directory as cookbook

Upvotes: 0

Views: 288

Answers (2)

segfault
segfault

Reputation: 80

If all files are in the same folder, you don't need to type each file that you want to include in the archive. Just invoke the command and specify their common folder like this:

zip -r cookbook.zip cookbook

All files inside the cookbook directory will be included in the zip archive.

Upvotes: 0

ooga
ooga

Reputation: 15501

Try

zip -r@ my.zip < listfile

The -@ flag tells zip to read file names from stdin.

Upvotes: 1

Related Questions