#!/bin/sh

if [ $# -ne 2 ]
then	echo "Usage: $0 <dir> <string>"
	exit 1
fi

dir="$1"
string="$2"

set -e

cd $dir
for f in *bz2
do	contents=$f.contents
	if [ \( ! -f $contents \) -o $f -nt $contents ]
	then	echo "Regenerating $contents .."
		bzip2 -dc $f | tar tf - >$contents || exit 1
	fi
done

grep $string *.contents 

