1758661 Members
2179 Online
108874 Solutions
New Discussion юеВ

Script Questions

 
SOLVED
Go to solution
rmueller58
Valued Contributor

Script Questions

I need to populate a TEMPLATE prior to running with some particular items.. I have a script that creates a flat file in columnar data format.

177
55
5994
5996
5997
....
varN

TEMPLATE --
select * from table
-- INSERT WHERE CLAUSE HERE
where id in ( '177','55','5994','5995','5997','varN' )

any ideas appreciated
3 REPLIES 3
Heironimus
Honored Contributor
Solution

Re: Script Questions

Untested, but something like this should do what you want:

echo 'select * from table where id in ('$(sed -e "s/^\\|\$/'/g" test.txt | paste -d, -s)');'
rmueller58
Valued Contributor

Re: Script Questions

Thank you..

STAGEDFILES=/mps-docs/mps-docs/mpsplustest/applicant/
cd $STAGEDFILES
rm -f /tmp/jac.txt
touch /tmp/jac.txt
for fn1 in `find -type f -mmin -360000 -print`
do
export fn=`echo $fn1| awk '{print substr($1,3,22)}'`
for appid in `echo $fn |awk -F_ '{print $2}'`
do
export distID=`echo $fn |awk -F_ '{print $1}'`
export appID=`echo $fn |awk -F_ '{print $2}'`
export docID=`echo $fn |awk -F_ '{print $3}'|cut -d. -f1`
export ext=`echo $fn |awk -F_ '{print $3}'|cut -d. -f2`

export ITERID=`echo 0`


echo $distID >> /tmp/jac.txt
done
done
sort /tmp/jac.txt |uniq > /tmp/jac1.txt
echo 'select * from table where id in ('$(sed -e "s/^\\|\$/'/g" /tmp/jac1.txt | paste -d, -s)');' > /tmp/TEMPLATE
more /tmp/TEMPLATE
cd


rmueller58
Valued Contributor

Re: Script Questions

See post above