Search code examples
zipphp-ziparchive

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


Solution

  • Try

    zip -r@ my.zip < listfile
    

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