Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

The thing is that it overwrites in Result.txt and I only get the last query. How can I fix this?

#!/bin/sh
while read -r line
do
  echo "'$line'"
  sqlplus -s whatever/whatever <<-EOF
  SPOOL Result.txt
  SELECT * FROM ---- WHERE sol = '$line';
  SPOOL OFF ;   
  exit;
EOF

done < evs.txt
share|improve this question

1 Answer 1

just add

 rm Results.txt

before the loop

and

 cat Result.txt >> Results.txt

after EOF (and before done).

share|improve this answer
    
Thanks but now there is sth wierd happening, now I get "no rows selected" in Results.txt and in the shell I get cat: Resultado3.txt: Source is same as Target. Skipping... –  danman Sep 2 at 9:12
    
"No Row selected" means query return no row. have you typed cat as mention in my answer ? –  Archemar Sep 2 at 9:15
    
Yeah now it's working!! Thanks a lot :) –  danman Sep 2 at 9:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.