Is there a way to use sed or awk to filter data inside a zipped file? When I run a sed or awk command and send to stdout the file created is 0 bytes.
1 Answer
Assuming a ZIP archive, as commonly found on MS‐DOS systems, under a unix command line prompt one might do:
% unzip -p -a files.zip | awk ...
where the ellipsis are replaced by your arguments to awk. Data input is received from standard input via the pipe. Replace unzip with the appropriate command if you're using another compression method and update your options appropriately.
zip
then you have an archive containingz zero or more files that are compressed, talking about "a zipped file" makes no sense in that context. If made bygzip
,xz
,bzip2
orcompress
, this is a compressed file. Please update your question to make clear what you are referring to, because zipped and compressed have different answers.