The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 09-05-2007
mvijayv mvijayv is offline
Registered User
 

Join Date: Jan 2007
Posts: 16
instead of using a zgrep ...try using a zcat as below
DIRECTORY=<Location where the files are located>
NEWDIR=<Desination folder>
for file in `ls -1 $DIRECTORY/*.Z`
do
LC=`zcat $file |head -1|grep "${STRING}"|wc -l`
if test $LC -eq 1
then
mv $file $NEWDIR/.
fi
done
Reply With Quote