How do you specify filenames within a zip when creating it on the command line from a pipe?

后端 未结 6 1848
面向向阳花
面向向阳花 2020-12-13 19:46

I\'m trying to create a zip file from file contents which are being piped in, e.g.

mysql [params and query] | zip -q output.zip -

This writ

6条回答
  •  隐瞒了意图╮
    2020-12-13 19:50

    You can do this.

    ls | zip test.zip -@
    

    this is done from the notion that i have 3 files in the dir.

    -rw-rw-r-- 1 xxx domain users   6 Jan  7 11:41 test1.txt
    -rw-rw-r-- 1 xxx domain users   6 Jan  7 11:41 test2.txt
    -rw-rw-r-- 1 xxx domain users   6 Jan  7 11:41 test3.txt
    

    and the file itself, the result is then

    Archive:  test.zip
      Length     Date   Time    Name
     --------    ----   ----    ----
            6  01-07-10 11:41   test1.txt
            6  01-07-10 11:41   test2.txt
            6  01-07-10 11:41   test3.txt
     --------                   -------
           18                   3 files
    

    From the Linux Zip Man page

    If the file list is specified as -@, zip takes the list of input files from standard input.

提交回复
热议问题