Hello. Here is the start of the quest.

The Process Generator transfers information to the Processor Process using a file. The “Processor” process should perform the following processing of new lines in this file: if the line contains a single “+” character, then the process is a processor ...

Continuation is not important. The question is how to handle new strings. I know that there is a tail command with the -f flag to monitor a file, but I can't shove it into my script. I tried it like this

while read s do echo $s done < $(tail -f "file.txt") 

did not work, blank lines are output. I also tried it like this

 while true do read s < "file.txt" echo $s done 

in infinite loop displays the first line. How to organize the reading of new lines?

    1 answer 1

    I am stupid ((In the example of the assignment it is written how to do it ((

     (tail -n 0 -f data.txt) | while true; do read LINE; case $LINE in QUIT) echo "exit" killall tail exit ;; *) echo $LINE ;; esac done 
    • Only here killall is somehow not good ... (what happens if you run several tasks causing tail at the same time?) M. better to replace it with kill ps -ef | grep $$$$ | grep tail | awk '{print $2}' ps -ef | grep $$$$ | grep tail | awk '{print $2}' ps -ef | grep $$$$ | grep tail | awk '{print $2}' - avp
    • one
      Yes, I understand this is a learning example. - sinedsem