In ksh, I have a while loop that reads two files. If current line of file 1 is Y then echo the current line of file 2 into new file and if current line of file 1 is N echo the string waste in winscp.

while IFS= read xxxx && IFS= read yyyy <&4; do
    if [[ ${xxxx} = "N" ]];then
          echo waste
          echo "$yyyy" .>> $newfile
done <"$file1" 4<"$file2"

But if the file 1 has first three lines as N and remaining seven as Y, instead on printing three times waste and the last seven lines of second file into new file, my Winscp is displaying 10 times waste while running the script.

  • What have you done to debug this? – Scott Oct 30 '18 at 17:45
  • I can't reproduce this with ksh93 nor with pdksh (nor with bash for that matter). – Kusalananda Oct 30 '18 at 17:55
  • How does Winscp have anything to do with this? – ilkkachu Oct 30 '18 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.