hi,
i'am trying to write a shell program which takes a data element
from one file(var/tmp/usr1/pools)and search that data element
in a zipped file in archive location/usr01/archive/PSta*.Z).
cat var/tmp/usr1/pools
FC5173
FI5178
BE5221
FE5229
ST1604
ls /usr01/archive/PSta*.Z
/usr01/archive/PStat.dat.021711.001609.Z
/usr01/archive/PStat.dat.021811.001608.Z
/usr01/archive/PStat.dat.021911.001608.Z
/usr01/archive/PStat.dat.022311.001608.Z
/usr01/archive/PStat.dat.022411.001608.Z
/usr01/archive/PStat.dat.022511.001608.Z
/usr01/archive/PStat.dat.022611.001608.Z
/usr01/archive/PStat.dat.022811.190155.Z
below program writes that zipped filename into a temp file(/var/tmp/usr1/fcount) if it finds the occurence.
#!/usr/bin/sh
fl='/usr01/archive/'
for i in `cat /var/tmp/usr1/pools`
do
for j in `ls ${fl}/*.Z | tr -s ' '| cut -d" " -f9 | cut -d\/ -f7`
do
count=`zcat $fl/$j | grep "$i" | wc -l`
if [ $count -eq 1 ] ; then
echo ${j} | grep "PSta*" >> /var/tmp/usr1/fcount
fi
done
done
lets consider that the data element found two files having it's occurence and wrote
two filenames to the temp file, Now my goal is to find the latest filename having that
occurence(data element).
the program is getting all the file names into /var/tmp/usr1/fcount where i 'am not able to get the latest
file for each data element
i've been trying without any success..will appreciate if any one help me out here.
thanks
kmr023
That's going to make the code many, many times slower...