Sponsored Content
Full Discussion: Shell script using loop
Top Forums Shell Programming and Scripting Shell script using loop Post 302435887 by alisha on Thursday 8th of July 2010 12:50:34 PM
Old 07-08-2010
Question Shell script using loop

Hi everyone,

I have n number of data in my file "temp" in following order.In each line table_name and
column_name are different.input data is in same format each query in three lines.

Code:
ALTER TABLE table_name
ADD  ( column_name1         VARCHAR2(10),
       column_name2  VARCHAR2(70)  );

ALTER TABLE table_name
ADD  ( column_name1         VARCHAR2(10),
       column_name2  VARCHAR2(70)  );

ALTER TABLE table_name
ADD  ( column_name1         VARCHAR2(10),
       column_name2  VARCHAR2(70)  );

I need to pick the table name from each line one by one and check that
this name exists in my another file "name" or not.
If the table name exists in the file "name" then i need to pick the column1_name,
column2_name..... and their data type which are after ADD.
In this way need to do above action to each data in file and stor them in a file
in the following format:

Code:
TABLE_NAME   COLUMN_NAME  DATATYPE


i have used the code

Code:
while read folder
folder=`awk '/ALTER/ { print $3; } ' data.txt`
do
  cd $folder
  echo "in" > test
  cd ..
  i=$[$i+1]
done < data.txt

but for this i m getting only one table_name with error.

can anybody help me with the script.I want my script in SH
Please help me with above asap.

Last edited by alisha; 07-08-2010 at 02:56 PM.. Reason: Code tags, please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If then else loop in Shell script

Hi Following is the code . When I give input as Bangalore,its dospalying Welcome to Hitech City. But say , if I select Delhi or US, its not displaying the corresponding message. Its still says Welcome to Hitech City. Seems that it not entering in the elif part. Please suggest. #!... (4 Replies)
Discussion started by: pankajkrmishra
4 Replies

2. Shell Programming and Scripting

Help with loop in a shell script

I just want to write a little script, that reads the lines from a file, echos somthing in a new tmp.file and then do some commands whith the tmp.files. while read -r line do echo "TEST=" > tmp.$$ echo "$line" >> tmp.$$ any_command < tmp.$$ done < $INPUTFILE But I think I have to... (2 Replies)
Discussion started by: elifchen
2 Replies

3. Shell Programming and Scripting

Loop in shell script

Dear experts, i am quite new to shell script please any one can help me in this regard i would like write a script which takes input in the form >./Test.sh a,10,b,20,c,30... in this way i can give input in any number which is not constant in the end through loop i want to... (3 Replies)
Discussion started by: vin_pll
3 Replies

4. Shell Programming and Scripting

while loop problem in c shell script

Hi all, i write a script c shell set i = 1 while ( $i <= $#array ) echo "$array" @ i++ end i want to set it to i = i +2 in that statement . Can anybody help me? ---------- Post updated at 02:46 PM ---------- Previous update was at 02:35 PM ---------- anybody not how to solve it??? (2 Replies)
Discussion started by: proghack
2 Replies

5. Shell Programming and Scripting

Help with IF statement with loop Shell Script

Hello I am very new to shell and I bought some books and trying to learn it. I started trying to write a script that will take a number and count it down to 1 with commas in between. This number can only be one argument. If lower than one or higher than one argument it sends an error message. ... (4 Replies)
Discussion started by: zero3ree
4 Replies

6. Shell Programming and Scripting

Avoiding For Loop in Shell Script

I am looking to a solution to the following problem. I have a very large file that looks something like this: Each group of three numbers on each line are three probabilities that sum to one. I want to output the maximum for each group of three. So desired output would be: or... (6 Replies)
Discussion started by: hydrabane
6 Replies

7. Shell Programming and Scripting

Help with the For loop shell script

Hi, I have multiple files in a directory. Each file will have a header.I have to check if any of the files has 0 rows other than the header then I have to delete the files. Here “ Empty file” in my case means a file has header information but no data. I have to delete such files. If the file... (2 Replies)
Discussion started by: ganesnar
2 Replies

8. Shell Programming and Scripting

Loop in shell script

Hi Friends, I have a file. the content is as below: file1: /A/B/C/abc.txt 2013-07-28 13:50:00,2013-07-31 01:00:00,5,710 /A/B/C/xyz.txt 2011-09-21 18:30:00,2013-07-30 06:15:00,15,65135 2009-11-09 18:00:00,2011-09-02 09:00:00,5,12345 2013-07-28 13:50:00,2013-07-31 01:00:00,5,710 ... (2 Replies)
Discussion started by: vsachan
2 Replies

9. Shell Programming and Scripting

Speed up the loop in shell script

Hi I have written a shell script which will test 300 to 500 IPs to find which are pinging and which are not pinging. the script which give output as 10.x.x.x is pining 10.x.x.x. is not pining - - - 10.x.x.x is pining like above. But, this script is taking... (6 Replies)
Discussion started by: kumar85shiv
6 Replies

10. Shell Programming and Scripting

Shell script use two variable in for loop

I want to create a shell script to add a user and modify its comment field mentioned in a file. 1. File value:- username comment field value xyz123 xyztesting abc123 abctesting def123 deftesting 2. i am using below loop to create user... (2 Replies)
Discussion started by: Anil
2 Replies
DBI::Shell(3)						User Contributed Perl Documentation					     DBI::Shell(3)

NAME
DBI::Shell - Interactive command shell for the DBI SYNOPSIS
perl -MDBI::Shell -e shell [<DBI data source> [<user> [<password>]]] or dbish [<DBI data source> [<user> [<password>]]] DESCRIPTION
The DBI::Shell module (and dbish command, if installed) provide a simple but effective command line interface for the Perl DBI module. DBI::Shell is very new, very experimental and very subject to change. Your milage will vary. Interfaces will change with each release. TO DO
Proper docs - but not yet, too much is changing. "/source file" command to read command file. Allow to nest via stack of command file handles. Add command log facility to create batch files. Commands: load (query?) from file save (query?) to file Use Data::ShowTable if available. Define DBI::Shell plug-in semantics. Implement import/export as plug-in module Clarify meaning of batch mode Completion hooks Set/Get DBI handle attributes Portability Emulate popular command shell modes (Oracle, Ingres etc)? COMMANDS
Many commands - few documented, yet! help /help chistory /chistory (display history of all commands entered) /chistory | YourPager (display history with paging) clear /clear (Clears the current command buffer) commit /commit (commit changes to the database) connect /connect (pick from available drivers and sources) /connect dbi:Oracle (pick source from based on driver) /connect dbi:YourDriver:YourSource i.e. dbi:Oracle:mysid Use this option to change userid or password. current /current (Display current statement in the buffer) do /do (execute the current (non-select) statement) dbish> create table foo ( mykey integer ) dbish> /do dbish> truncate table OldTable /do (Oracle truncate) drivers /drivers (Display available DBI drivers) edit /edit (Edit current statement in an external editor) Editor is defined using the enviroment variable $VISUAL or $EDITOR or default is vi. Use /option editor=new editor to change in the current session. To read a file from the operating system invoke the editor (/edit) and read the file into the editor buffer. exit /exit (Exits the shell) get /get (Retrieve a previous command to the current buffer) go /go (Execute the current statement) Run (execute) the statement in the current buffer. This is the default action if the statement ends with / dbish> select * from user_views/ dbish> select table_name from user_tables dbish> where table_name like 'DSP%' dbish> / dbish> select table_name from all_tables/ | more history /history (Display combined command and result history) /history | more option /option [option1[=value]] [option2 ...] /option (Displays the current options) /option MyOption (Displays the value, if exists, of MyOption) /option MyOption=4 (defines and/or sets value for MyOption) perl /perl (Evaluate the current statement as perl code) quit /quit (Leaves shell. Same as exit) redo /redo (Re-execute the previously executed statement) rhistory /rhistory (Display result history) rollback /rollback (rollback changes to the database) For this to be useful, turn the autocommit off. /option autocommit=0 table_info /table_info (display all tables that exist in current database) /table_info | more (for paging) trace /trace (set DBI trace level for current database) Adjust the trace level for DBI 0 - 4. 0 off. 4 is lots of information. Useful for determining what is really happening in DBI. See DBI. type_info /type_info (display data types supported by current server) AUTHORS and ACKNOWLEDGEMENTS The DBI::Shell has a long lineage. It started life around 1994-1997 as the pmsql script written by Andreas Konig. Jochen Wiedmann picked it up and ran with it (adding much along the way) as dbimon, bundled with his DBD::mSQL driver modules. In 1998, around the time I wanted to bundle a shell with the DBI, Adam Marks was working on a dbish modeled after the Sybase sqsh utility. Wanting to start from a cleaner slate than the feature-full but complex dbimon, I worked with Adam to create a fairly open modular and very configurable DBI::Shell module. Along the way Tom Lowery chipped in ideas and patches. As we go further along more useful code and concepts from Jochen's dbimon is bound to find it's way back in. COPYRIGHT
The DBI::Shell module is Copyright (c) 1998 Tim Bunce. England. All rights reserved. Portions are Copyright by Jochen Wiedmann, Adam Marks and Tom Lowery. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. perl v5.8.0 2002-11-29 DBI::Shell(3)
All times are GMT -4. The time now is 05:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy