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 the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 08-29-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Try this:


Code:
nawk -v v="'" '{ print("select " v ":" $1":" v "||count(*) from "$1";"); }' tablenames > count.sql

sqlplus -s username/password@dbname <<! > count.log
set linesize 1000 pagesize 0 heading off feedback off trimspool on;
@count.sql
!

grep "^:" count.log

In the log file you will have the output in this format:


Code:
:TABLE1:10
:TABLE2:20
:TABLE3:30
...
:TABLEn:<count>

In this manner you can easily grep/cut the information you need from the log file.