How to variables to cut command in unix for -f option -
i need parse sql
file , pull statements.
for example sample.sql
this
alter table add column(c1 varchar(20)); alter table add column(c2 varchar2(10));
now want write script in below manner.
#!/bin/ksh file in sample.sql echo $file no_of_statement=`grep ";" $file|wc -l` echo $no_of_statement iterator=1 statement="" while [ $iterator -le $no_of_statement] echo "inside while loop" statement=`cat $file` statement1=`echo $statement | cut -d";" -f "${iterator}"` echo $statement1 iterator=$iterator+1 done done
if change [ $iterator -le $no_of_statement]
[ $iterator -le $no_of_statement ]
and iterator=$iterator+1
iterator=$(($iterator+1))
it prints queries:
sample.sql 2 inside while loop alter table add column(c1 varchar(20)) inside while loop alter table add column(c2 varchar2(10))
Comments
Post a Comment