You did not tag zip, but the filename contains
.zip, so I assume after decrypting it's really a zip file.
See this answer:
The ZIP file format includes a directory (index) at the end of the archive. This directory says where, within the archive each file is located and thus allows for quick, random access, without reading the entire archive.
This would appear to pose a problem when attempting to read a ZIP archive through a pipe, in that the index is not accessed until the very end and so individual members cannot be correctly extracted until after the file has been entirely read and is no longer available. As such it appears unsurprising that most ZIP decompressors simply fail when the archive is supplied through a pipe.
The directory at the end of the archive is not the only location where file meta information is stored in the archive. In addition, individual entries also include this information in a local file header, for redundancy purposes.
Although not every ZIP decompressor will use local file headers when the index is unavailable, the
cpio front ends to
bsdcpio) can and will do so when reading through a pipe, […]
In my Debian 9 the solution with
libarchive-tools package) works:
gpg --decrypt file.zip.gpg | bsdtar -xvf-
Other answers provide other solutions. Some of them do use a temporary file in disguise (e.g.
=( … ) in zsh), some of them don't (e.g.
busybox unzip -, but this one doesn't work for me).
If the format was 7z instead of zip, then the problem would be similar. Compare this thread:
Trying to pipe through
I'm trying to run
7za in a pipeline within a C++ program. […]
Same thing if I try to do it on the command line.
7za e -an -si -so < filename.7z >/dev/null
Can not open the file as archive
The answer from Igor Pavlov (the creator of 7-zip) is:
7-zip needs "seek" operation for 7z archives. So you can't use
-si to extract from 7z archive.
This was dated 2016-03-30. My tests and the changelog indicate the statement is still valid in 2019. Moreover
bsdtar in my Debian cannot help, it yields
Error seeking in stdin. I guess the 7z format really needs a seekable file.