1

This is my code:

while IFS=',' read a b c; do read input echo $input done 3<&0 < input.csv > output.txt 

I took care of input redirection by redirecting through pipeline. But still,when I run the above code, control does not stop for input.

Why?

    1 Answer 1

    4

    It's because your input stream is feeding both read. You're almost right, so maybe it's a typo (you just forgot to give to right FD to your second read) :

    while IFS=',' read a b c; do read input <&3 echo $input done 3<&0 < input.csv >> output.txt 
    2
    • yeah I missed that, thanks again. I can read input from while loop now, however when I try the same inside a function called in while loop, it does not work.
      – Menon
      CommentedApr 7, 2015 at 14:38
    • 1
      @Menon Why? You just have to replace your read input <&3 by my_function <&3 and it should work.
      – apaul
      CommentedApr 7, 2015 at 14:57

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.