read the files one by one in a zip file using bash
问题 I want to open the files inside a .zip file and read them. In this zip file, I have numerous .gz files, like a.dat.gz, b.dat.gz, and so on. My code so far: for i in $(unzip -p sample.zip) do for line in $(zcat "$i") do # do some stuff here done done 回答1: You are correct in needing two loops. First, you need a list of files inside the archive. Then, you need to iterate within each of those files. unzip -l sample.zip |sed ' /^ *[0-9][0-9]* *2[0-9-]* *[0-9][0-9]:[0-9][0-9] */!d; s/// ' |while