zip up files listed in a file - Unix

This is a discussion on zip up files listed in a file - Unix ; Hi, I have a list of files in a text file which I'd like to zip up, but zip doesn't seem to offer this as an option eg zip all.zip -l list.txt my zip This is Zip 2.3 (November 29th ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: zip up files listed in a file

  1. zip up files listed in a file

    Hi,
    I have a list of files in a text file which I'd like to zip up, but zip
    doesn't seem to offer this as an option eg zip all.zip -l list.txt

    my zip
    This is Zip 2.3 (November 29th 1999), by Info-ZIP.

    I solved this by turning the list into shell with
    zip all.zip file1
    zip all.zip file2
    etc etc

    But there is surely a better way?

    zzapper


  2. Re: zip up files listed in a file

    david@tvis.co.uk wrote:
    > Hi,
    > I have a list of files in a text file which I'd like to zip up, but zip
    > doesn't seem to offer this as an option eg zip all.zip -l list.txt
    >
    > my zip
    > This is Zip 2.3 (November 29th 1999), by Info-ZIP.
    >
    > I solved this by turning the list into shell with
    > zip all.zip file1
    > zip all.zip file2
    > etc etc
    >
    > But there is surely a better way?
    >
    > zzapper
    >


    xargs zip all.zip
    --
    Michael Tosch @ hp : com

  3. Re: zip up files listed in a file

    Hi
    Neither solution works for me

    $ zip all.zip $(cat list.txt)
    zip warning: name not matched: x1
    zip warning: name not matched: x2
    zip warning: name not matched: x3

    does work if I join all the lines of list.txt into one long line eg
    x1 x2 x3


    (I think one of your scripts suggest this)
    zzapper


  4. Re: zip up files listed in a file

    Begin <1131112132.954123.15920@g49g2000cwa.googlegroups.c om>
    On 2005-11-04, david@tvis.co.uk wrote:
    > I have a list of files in a text file which I'd like to zip up, but zip
    > doesn't seem to offer this as an option eg zip all.zip -l list.txt
    >
    > my zip
    > This is Zip 2.3 (November 29th 1999), by Info-ZIP.


    Then see zip(1) and look for -@


    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .

  5. Re: zip up files listed in a file

    david@tvis.co.uk wrote:
    > Hi
    > Neither solution works for me
    >
    > $ zip all.zip $(cat list.txt)
    > zip warning: name not matched: x1
    > zip warning: name not matched: x2
    > zip warning: name not matched: x3
    >
    > does work if I join all the lines of list.txt into one long line eg
    > x1 x2 x3
    >


    I guess you have created a DOS style .txt file.
    Then convert to Unix via "dos2unix".
    E.g.

    dos2unix list.txt | xargs zip all.zip


    --
    Michael Tosch @ hp : com

  6. Re: zip up files listed in a file


    jpd wrote:
    > Begin <1131112132.954123.15920@g49g2000cwa.googlegroups.c om>
    > On 2005-11-04, david@tvis.co.uk wrote:
    > > I have a list of files in a text file which I'd like to zip up, but zip
    > > doesn't seem to offer this as an option eg zip all.zip -l list.txt
    > >
    > > my zip
    > > This is Zip 2.3 (November 29th 1999), by Info-ZIP.

    >
    > Then see zip(1) and look for -@
    >


    For a file list.txt containing one file name per line
    the following turned out to be my prefered solution:-

    zip all.zip -@ < list.txt

    seems slightly arcane

    note also the useful

    find . -name "*.[ch]" -print | zip source -@

    --
    zzapper
    Success for Techies
    http://SuccessTheory.com/ vim, zsh & success tips


  7. Re: zip up files listed in a file

    david@tvis.co.uk wrote:
    > I have a list of files in a text file which I'd like to zip up, but zip
    > doesn't seem to offer this as an option eg zip all.zip -l list.txt


    > I solved this by turning the list into shell with
    > zip all.zip file1
    > zip all.zip file2
    > etc etc
    > But there is surely a better way?


    Not much, but a couple of options come to mind
    1) Put the filenames rather in a for loop.
    2) Write a script that in turn writes your shell script based on
    sed or awk.

    The latter has the advantage of being more generic. In fact you can
    simulate your requirement with that method.

    All the best, Timo

    --
    Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
    Department of Accounting and Business Finance ; University of Vaasa
    mailto:ts@uwasa.fi ; FIN-65101, Finland
    Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

+ Reply to Thread