Bash: reading input within while read loop doesn't work

well actually

Reading input within a while read loop does not seem to work

while read line
do
 echo "get some input from the user"
 read response
done < some_file.txt

execution does not pause like it would had the read been outside the loop. Why is this? Is there a workaround for reading input within a while read loop?

Nifle

The problem is that both read line and read response expects (and gets) data from stdin.
This question on SO explains some of it with a link to even more information.

tl;dr
The accepted answer suggests:

Read from the controlling terminal device: read input </dev/tty

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Bash exec in infinite while loop doesn't work

분류에서Dev

WAITFOR DELAY doesn't act separately within each WHILE loop

분류에서Dev

Switch statement within Do-While loop doesn't exit

분류에서Dev

bash: Prompting for user input while reading file

분류에서Dev

Scanf to check reading of integer doesn't work

분류에서Dev

Gigya doesn't work with Facebook while Google and Yahoo do work

분류에서Dev

Panels' Autoscroll with expanding Panel within doesn't work

분류에서Dev

element.on('click') on a directive within ng-if doesn't work

분류에서Dev

reading input from user in a loop

분류에서Dev

Validation for input box, use Jquery focusin function doesn't work

분류에서Dev

Input Doesn't Work as Expected When Overlaying a Fragment in Main activity

분류에서Dev

focus() on input that is inside hidden div doesn't work

분류에서Dev

script in cronjob doesn't work with: "Could not open input file"

분류에서Dev

Batch: Doing a whois command in a loop doesn't seem to work

분류에서Dev

Why the promise doesn't work when outside of the loop?

분류에서Dev

Why doesn't Bash completion for 'cc' and 'c++' work?

분류에서Dev

Multiple find -exec commands in one bash script doesn't work?

분류에서Dev

BASH - Simple script with rm command doesn't work

분류에서Dev

Can't get a while, or do... while loop to work, looked up multiple answers. nothing works

분류에서Dev

Infinite while loop passing a string as a while argument on Java, the variable value doesn't change

분류에서Dev

do while loop with input scanner

분류에서Dev

Check if input is a number in a while loop

분류에서Dev

Infinity loop while reading data from file

분류에서Dev

Bash while loop sed replace

분류에서Dev

Mistake in while loop? bash script

분류에서Dev

Bash while loop with substring condition

분류에서Dev

unbind doesn't work

분류에서Dev

Crontab doesn't work

분류에서Dev

Why doesn't `cat foo.txt | while read` fail if file not found?

Related 관련 기사

  1. 1

    Bash exec in infinite while loop doesn't work

  2. 2

    WAITFOR DELAY doesn't act separately within each WHILE loop

  3. 3

    Switch statement within Do-While loop doesn't exit

  4. 4

    bash: Prompting for user input while reading file

  5. 5

    Scanf to check reading of integer doesn't work

  6. 6

    Gigya doesn't work with Facebook while Google and Yahoo do work

  7. 7

    Panels' Autoscroll with expanding Panel within doesn't work

  8. 8

    element.on('click') on a directive within ng-if doesn't work

  9. 9

    reading input from user in a loop

  10. 10

    Validation for input box, use Jquery focusin function doesn't work

  11. 11

    Input Doesn't Work as Expected When Overlaying a Fragment in Main activity

  12. 12

    focus() on input that is inside hidden div doesn't work

  13. 13

    script in cronjob doesn't work with: "Could not open input file"

  14. 14

    Batch: Doing a whois command in a loop doesn't seem to work

  15. 15

    Why the promise doesn't work when outside of the loop?

  16. 16

    Why doesn't Bash completion for 'cc' and 'c++' work?

  17. 17

    Multiple find -exec commands in one bash script doesn't work?

  18. 18

    BASH - Simple script with rm command doesn't work

  19. 19

    Can't get a while, or do... while loop to work, looked up multiple answers. nothing works

  20. 20

    Infinite while loop passing a string as a while argument on Java, the variable value doesn't change

  21. 21

    do while loop with input scanner

  22. 22

    Check if input is a number in a while loop

  23. 23

    Infinity loop while reading data from file

  24. 24

    Bash while loop sed replace

  25. 25

    Mistake in while loop? bash script

  26. 26

    Bash while loop with substring condition

  27. 27

    unbind doesn't work

  28. 28

    Crontab doesn't work

  29. 29

    Why doesn't `cat foo.txt | while read` fail if file not found?

뜨겁다태그

보관