Avatar of joaotelles
joaotelles
Flag for United States of America asked on

Shell script syntax

Hi,

Im trying to write a script for the following:

I have a file with a list of numbers (over 300)

So I want to input them into a SQL statament:

select * from todo where TODD='89014104254327F';

And them thrown it it a file.

So I thought something like this (not sure of the syntax)

while [ condition until the file finishes ]
do
output=`sqlplus -s ${db_user}/${db_pass}@${SID} <<!
      set heading off
      set feedback off
      select * from todo where TODD=${variable};
      exit;
      !`

${output} >> ultimate_file.txt

some counter for the condition??

done


===================

The file with the numbers looks like this:

525245
252524
252345
234245
242342
123123
144144
.
.


Tks,
joao
Shell Scripting

Avatar of undefined
Last Comment
joaotelles

8/22/2022 - Mon
sakman

You can do something like this in shell:

for line in `cat filename`
do

    output=...

done

Open in new window

joaotelles

ASKER
So it would be:

for line in `cat filename`
do

    output=...

done

====

No counter needed?

To put the output in a file is it ok?

${output} >> ultimate_file.txt
ASKER CERTIFIED SOLUTION
sakman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
joaotelles

ASKER
tks
Your help has saved me hundreds of hours of internet surfing.
fblack61