Given a set of zip files, is there an easy way to list only those zipfiles that contain files whose names match a given pattern, cf. using
grep -l to list only files whose contents contain lines matching a given pattern?
The best I've been able to come up with is
for i in $ZIPFILE_LIST > do j=$(basename $i) > unzip -l $i > /tmp/$j > grep -l $PATTERN /tmp/$j > rm /tmp/$j > done
but it's fairly hacky and without e.g. passing the
grep output through
sed (with various escaping headaches) it's going to tell you which files you care about, but it's not actually going to give you the full paths in a form you can then pass on to something else. It seems like this is a reasonably common use case and there ought to be some better out-of-the-box tool or combination of tools to do it.