0

Say I have a *.zip file, and want to use the unzipped files - more precisely the filenames - directly as input to another command in the terminal. How could this be accomplished?

An example:
- I have a zip-file containing several pdf-files
- I want to merge the pdf-files to one, using e.g. ghostscript

gs -sDEVICE=pdfwriter -sOutputFile=out.pdf <pdf-files from zip>
some_user
  • 111
  • 5
  • 1
    Does this answer your question? [How to unzip a file in terminal and spit it out with specific file name?](https://askubuntu.com/questions/642834/how-to-unzip-a-file-in-terminal-and-spit-it-out-with-specific-file-name) – David Apr 23 '20 at 08:42
  • Filename***s*** might be difficult, but singular extracted files are possible. – David Apr 23 '20 at 08:43
  • Does this answer your question? [How to mount a zip file as a file system?](https://askubuntu.com/questions/94649/how-to-mount-a-zip-file-as-a-file-system) – pLumo Apr 23 '20 at 09:43
  • with avfs, you can access your zip files directly `~/.avfs/home/$USER/path/to/file.zip#/files*` – pLumo Apr 23 '20 at 09:44

1 Answers1

0

Append/concat .pdf files from a zip file:

$ > out.pdf; xargs -a <(zipinfo -1 in.zip) -I {} \
  sh -c 'mv out.pdf tmp.pdf; unzip -p in.zip "$1" | \
  gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -o out.pdf tmp.pdf -' _ {}

Using fuse-zip:

$ mkdir -p zip && fuse-zip -r in.zip zip && \
  gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -o out.pdf zip/* && fusermount -u zip
  • think you will end up with some kind of temp file or directory either way. –  Apr 23 '20 at 13:20