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