shell - How to read from file *and* stdin in bash -
This is my job: read some data from the file line from the line, for each row, if it satisfies some condition , Ask the user to input some and proceed according to user input.
I know how to read a line-by-line content from a shell script: However, if I want to interact with the user inside loop body, conceptually, what I want is: Should I use another way of reading files? Or open the file on a file descriptor except for standard reading? "post-text" itemprop = "text"> For example: line while reading; Echo $ line $ & lt; File.txt
while reading; Do echo "This is what you want: $ line [y] es / [n] o" # This problem is: # I want to read from some standard input here. # However, inside the loop body, the standard input is redirected to file.txt INPUT if [[INPUT == "Y"]]; Then fixed the $ line & lt; File.txt
read -u 3 line; Read from FD3 read # -P "Y or N:" read the INPUT # standard input if [[INPUT == "Y"]]; Then the $ 3 file for the input line
Comments
Post a Comment