On Sat, 07 May 2005 23:58, Wesley Parish wrote:
> I need a command line script to find a file with a specific regular
> expression, in a directory full of ZIPped files - and the regular expression
> is in one of the ZIPped files.
>
> I know I can do "find /<directory> -exec 'grep "<regex>"'
> or words to that effect - I just don't know how to get it grepping a ZIPped
> file - if it was gziped I'd be using "zless" at some point in the command
> line above.
what about something like:-
for zf in `ls *.{ZIP,zip}`
do
unzip -p $zf | grep $1 - > /dev/null
if [ 0 -eq $? ]
then
echo "Expression $1 found in file: $zf"
fi
done
Pedestrian and slow hack, maybe, but it works!
regex as single argument.
--
C. S.