다음은 필자의 작업입니다. 한 줄씩 파일에서 일부 데이터를 읽으십시오. 각 행에 대해 조건을 만족하면 입력을 요구하고 사용자의 입력에 따라 진행합니다. bash에서 파일 * 및 * stdin을 읽는 방법
나는 쉘 스크립트에서 콘텐츠를 한 줄 한 줄을 읽는 방법을 알고while read line; do
echo $line
done < file.txt
그러나, 제가 루프 본체 내부의 사용자 와 상호 작용합니다. 개념적으로, 내가 원하는 것은 다음과 같습니다.
while read line; do
echo "Is this what you want: $line [Y]es/[n]o"
# Here is the problem:
# I want to read something from standard input here.
# However, inside the loop body, the standard input is redirected to file.txt
read INPUT
if [[ $INPUT == "Y" ]]; then
echo $line
fi
done < file.txt
파일을 읽는 다른 방법을 사용해야합니까? stdin을 읽는 다른 방법?
중복 가능성 [판독 루프 내 떠들썩한 파티 표준 입력을 판독 (http://stackoverflow.com/questions/8886683/read-stdin-bash-within-a-read-loop) – BroSlow