need help to print the below ..
Content of file looks like below ..
SCHEMA1. TABLE1
SCHEMA2. TABLE2
SCHEMA3. TABLE3
read lines from above file and print o/p as below
print output like read 1st line and print
SELECT SCHEMA1.TABLE1
print output like read 2st line and print
SELECT SCHEMA2.TABLE2
print output like read 3rd line and print
SELECT SCHEMA3.TABLE3
As always, where exactly are you stuck with this?
i tried this way ...
Tablist.txt has
SCHEMA1. TABLE1
SCHEMA2. TABLE2
SCHEMA3. TABLE3
TABNAME =$(cat Tablist.txt|awk '{print $2 }')
TABSCHEMA=$(cat Tablist.txt|awk '{print $1}')
later i need help in printing this way .
for given number of lines below echo should be repeated ..
do
echo "select *from TABSCHEMA.TABNAME "
done
how about: sed 's/ *//g;s/^/select * from /' Tablist.txt
With shell builtins we are close to your initial attempts :
while read tabschema tabname
do
echo "select * from $tabschema.$tabname"
done < Tablist.txt