Goal:
I want to create a script that will verify the file count and the file names against a static base file.
I will have a static basefile that will have Multiple Dir Names, Names of files in those multiple Directories, and a count of all files in the multiple dirs. The script that I need help with will use this static basefile for comparison.
I would like to have a script that will verify all files in there specfic dirs are present by using this static basefile. I would like the script to create an output that will name the file that is missing and the number of files. Will be dealing with about 15 different directories within the Basefile. I am not sure how to creat the base file either. We have a machine here that has all our third party stuff on it and it is dev machine that we can do an "ls /DIR/*/* | wc -l >> basefile" but all this gives me is a word count. How do I get the name of the file and the number only in the output?
This is what MR. Dickie has helped out with, he is a great member of this site. A wonderful contributor.
#!/bin/ksh
auditlog=/logdir/logfile
echo " File count test " > $auditlog
for dirs in /adir /bdir /cdir /ddir
do
basecount=`cat ${dirs}/basefile` #contains no. of files
dircount=`ls ${dirs/*|wc -l`
if [ $dircount -ne $basecount ]
then
echo "Imbalance in $dirs - Count=$dircount - Should be $basecount" >> $auditlog
else
echo "OK in $dirs - Count=$dircount - Same as $basecount" >> $auditlog
fi
done
I want to create a script that will verify the file count and the file names against a static base file.
I will have a static basefile that will have Multiple Dir Names, Names of files in those multiple Directories, and a count of all files in the multiple dirs. The script that I need help with will use this static basefile for comparison.
I would like to have a script that will verify all files in there specfic dirs are present by using this static basefile. I would like the script to create an output that will name the file that is missing and the number of files. Will be dealing with about 15 different directories within the Basefile. I am not sure how to creat the base file either. We have a machine here that has all our third party stuff on it and it is dev machine that we can do an "ls /DIR/*/* | wc -l >> basefile" but all this gives me is a word count. How do I get the name of the file and the number only in the output?
This is what MR. Dickie has helped out with, he is a great member of this site. A wonderful contributor.
#!/bin/ksh
auditlog=/logdir/logfile
echo " File count test " > $auditlog
for dirs in /adir /bdir /cdir /ddir
do
basecount=`cat ${dirs}/basefile` #contains no. of files
dircount=`ls ${dirs/*|wc -l`
if [ $dircount -ne $basecount ]
then
echo "Imbalance in $dirs - Count=$dircount - Should be $basecount" >> $auditlog
else
echo "OK in $dirs - Count=$dircount - Same as $basecount" >> $auditlog
fi
done