The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 02-20-2007
yarik20 yarik20 is offline
Registered User
 

Join Date: Feb 2007
Posts: 2
Thank you so much, i'll test it from work.

Quote:
Originally Posted by aigles
You can do something like that :
Code:
##!/bin/bash

SCRIPT_DIR=$(dirname $0)
SCRIPT_DIR=$(cd $SCRIPT_DIR && pwd)
DATA_DIR=${SCRIPT_DIR}/../../installer/data/
SOURCE_DIR_MAINT=/cygdrive/c/maint_view/RBS

# Get parameters

if [ $# -lt 2 ]
then
   echo "Usage: $0 label database_string" 1>&2
   exit 1
fi
Label=$1 ; shift
Database_string="$*"          


echo "######################UPDATING MAINTANANCE VIEW##########################  "
#update view
(cd $SOURCE_DIR_MAINT; cleartool update) >log.lst

cd $DATA_DIR
cleartool find . -name '*.sql' -cview -version "{!lbtype(${Label})}' -nxname -print | \
sed -e 's/[.]\\//g' -e 's/_data[.]sql//g'                                           | \
sort >file.lst

echo ===============================================================================================
for f in `cat file.lst`; do count=$(grep "insert into" ${f}_data.sql|wc -l); echo "$f,$count"; done
echo ===============================================================================================

echo "set heading off;" >counter.sql
for f in `cat file.lst`; do echo "select '$f,'||count(*) from $f;" ; done >>counter.sql
echo "quit" >> counter.sql
cat counter.sql
for f in `cat file.lst`; do count=$(grep "insert into" ${f}_data.sql|wc -l); echo "$f,$count"; done >version_controlcount.txt
sqlplus -S ${Database_string} | sed -e '/^$/d' >db_count.txt
cat db_count.txt
diff version_control_count.txt db_count.txt
exit 0
Jean-Pierre.
Reply With Quote