Finding tables from each script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding tables from each script
# 1  
Old 06-17-2008
Finding tables from each script

Hi,

I just want to take each sql script from specified directory and print all tables in those sqls. Below is the script but getting an error lik

ksh: 0403-057 Syntax error: `(' is not expected.

Script is----

ls /ukdw/prd/working/TDMatrix/srualcb02/ukdw/prd/bin | awk '{printf("%s ",$0)}END{print "\n"}'
for(sc=1;sc<=NF;sc++)
{
grep -iE "ABC|DEF" /ukdw/prd/working/TDMatrix/srualcb02/ukdw/prd/bin/$sc | awk '{printf("%s ",$0)}END{print "\n"}' | sed 's/,/ /g;s/ / /g' |
awk 'BEGIN{FS=" "}
{
for(i=1;i<=NF;i++)
{
fieldToCheck=toupper($i);
if (index(fieldToCheck,"ABC")>0){print $i};
if (index(fieldToCheck,"DEF")>0){print $i}
}
}'
}


PLZ suggest

Last edited by subrat; 06-17-2008 at 03:18 AM..
# 2  
Old 06-17-2008
The for loop is not in shell syntax. It looks like a piece of awk script.

From your problem description, I would guess you mean something like

Code:
for sc in /ukdw/prd/working/TDMatrix/srualcb02/ukdw/prd/bin/*; do
    grep -iwoE "ABC|DEF" "$sc"
done

which of course can be further simplified to

Code:
grep -iwohE "ABC|DEF" /ukdw/prd/working/TDMatrix/srualcb02/ukdw/prd/bin/*

I'm wildly speculating about what you want the inner loop to do here, but your problem description sounds like the above would be closer to what you really want than what you have now. Perhaps you can explain in more detail what input file looks like, and what you want to extract from it.
# 3  
Old 06-17-2008
Finding tables from each script

Thanks for the replay.


My outer loop is just taking one file at a time from the specified directory.
My second loop is taking that file and doing some search operation based on some criteria.

I tested the second loop alone and it is working fine. Just having problem to put an outer loop which ll give one by one file name to the second loop.

Hope i am making sence.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script writing for tables with binary data

Hi There, I'm trying to write a simple script that will email me when we have an application job in a certain status that needs human intervention. I've used this script for other tables and it works great. However, this one gives me the warning that there is binary data so it might not. ... (2 Replies)
Discussion started by: Colel2
2 Replies

2. Shell Programming and Scripting

Arranging the output of a shell script into tables

Hi guys. I am new to this forum so cheers :) I have a question. I have created a shell script that puts all the output into 1 file. The out put is like this: -----IP------ Data Data Data -----IP------ Data Data Data How can i arrange this to be like this: IP | Data |... (3 Replies)
Discussion started by: Pandera
3 Replies

3. Shell Programming and Scripting

How to use V$tables in UNIX shell script?

Hi All, In my script I have used the below code to retrieve the instance name V_INSTANCE_NAME=`sqlplus -s ${APPS_USR_PSWD} <<+ set pagesize 0 linesize 256 feedback off verify off head off echo off set serveroutput off select... (2 Replies)
Discussion started by: kalidoss
2 Replies

4. Shell Programming and Scripting

Need help in updating the tables inside shell script

I have an input file with contents like : 1LMXTJJD0W28TX2 1LS1XJGDEVWAC5T 1LK81JVDE2HRNDG 1LMXTJJD0W28TX2 1LS1XJGDEVWAC5T 1LK81JVDE2HRNDG 1LMXTJJD0W28TX2 I need to read each field from the file pass it to a query: select count(*) from usage_error where usage_id='$field... (17 Replies)
Discussion started by: Rajesh Putnala
17 Replies

5. Shell Programming and Scripting

Help is Script inserting in db2 tables

Hi, I am creating a shell script to insert few records in db2 tables. I am facing 2 challenges and would appreciate your help on this. 1) In my insert statement like follows: db2 "connect to dbname user user_name"; db2 "insert into table_name (name, phone, ssn) values... (1 Reply)
Discussion started by: pinnacle
1 Replies

6. Shell Programming and Scripting

Shell script for comparing data of tables

Hi, I have two databases with same tables on different servers.I need to check the data content in each table and if something is missing, should print that. I have a tool which takes the snapshot the table structure,index so on and compares with the other server tables snapshot. Now i need... (1 Reply)
Discussion started by: nessj
1 Replies

7. Shell Programming and Scripting

compare two tables using shell script

Hi, I want to compare two tables fieldwise using shell script. Can anyone help me regarding the same. The approach which i tried is to first move the two tables in simple txt file where each field is now seperated by space. But i can't retrive each field with "space" as a seperator b'coz there... (1 Reply)
Discussion started by: dtidke
1 Replies

8. Shell Programming and Scripting

Converting tables of row data into columns of tables

I am trying to transpose tables listed in the format into format. Any help would be greatly appreciated. Input: test_data_1 1 2 90% 4 3 91% 5 4 90% 6 5 90% 9 6 90% test_data_2 3 5 92% 5 4 92% 7 3 93% 9 2 92% 1 1 92% ... Output:... (7 Replies)
Discussion started by: justthisguy
7 Replies

9. UNIX for Dummies Questions & Answers

finding out tables not used in scripts.

Hi all, Please see my requirement and post me asap. Spool all the tables names into a file . Take each table name and check if it is present in any of the scripts in a directory using grep -il command. The script has to loop through the tables list and take each table and find it's presence... (7 Replies)
Discussion started by: Vasundhara
7 Replies
Login or Register to Ask a Question