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?
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] 삭제
몇 마디 만하겠습니다