The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
running command in while loop gefa Shell Programming and Scripting 2 11-21-2007 07:27 AM
Help with a simple loop command! dfs Shell Programming and Scripting 8 05-18-2007 02:27 PM
Pb in while loop with ssh command madmat Shell Programming and Scripting 1 10-13-2005 03:45 AM
rsh command in a while loop Nicol Shell Programming and Scripting 6 11-19-2003 01:08 PM
Using cat command in a for loop sleepster UNIX for Dummies Questions & Answers 1 09-12-2003 02:19 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-05-2007
Vaddadi Vaddadi is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 8
for loop with db2 command

Having some trouble with usage of for loop and displaying words. Basically I had 3 words( some times more )
in the variable. I want to get one at a time to process.

I am new to unix scripting so please bear with my question and appreciate your reply. I think this can also me done my awk command but I don't know how.. So appreciate your help.

Shell script is
=================
table_name='TAB_NAME'
schema_name='SCH_NAME'
db2 "connect to DB2D"

tempfile1=`db2 -x "select concat(pkgschema,concat('.',pkgname)) from
syscat.packagedep where bname='"$table_name"' and
bschema='"$schema_name"' with ur "`
echo ' ---tempfile after the db2 command ------- ' $tempfile1
for variable in $tempfile1; do
echo $tempfile1[0]
done

db2 "connect reset"


After the db2 command tempfile1 looks like ( 3 words seperated by blank)
sch1.package1 sch2.package2 sch3.package3

In the for loop also it shows like
sch1.package1 sch2.package2 sch3.package3 [0]
sch1.package1 sch2.package2 sch3.package3 [0]
sch1.package1 sch2.package2 sch3.package3 [0]


Expected output is
====================
sch1.package1
sch2.package2
sch3.package3
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0