1

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
  • 4
    What do you mean with zipped file? If it made by 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 by gzip, xz, bzip2 or compress, this is a compressed file. Please update your question to make clear what you are referring to, because zipped and compressed have different answers.
    – Anthon
    Apr 10, 2015 at 16:27

1 Answer 1

3

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.

Not the answer you're looking for? Browse other questions tagged .