Looping through lines in a file in bash, without using stdin

后端 未结 3 709
无人及你
无人及你 2021-01-05 06:01

I am foxed by the following situation.

I have a file list.txt that I want to run through line by line, in a loop, in bash. A typical line in list.txt has spaces in.

3条回答
  •  清酒与你
    2021-01-05 06:32

    You must open as a different file descriptor

    while read p <&3; do
        echo "$p"
        echo 'Hit enter for the next one'
        read x
    done 3< list.txt
    

    Update: Just ignore the lengthy discussion in the comments below. It has nothing to do with the question or this answer.

提交回复
热议问题