When a script is reading text file I would like this code to run specific command when it finds a specific string within a specific variable.
Let's say that I would like to use the following code to read the output of the command
#!/bin/bash for i in `last`; do sleep 0.1 | echo -ne "$i " done
The output of the command
last is a table in the form of a list of entries, something like:
username pts/2 220.127.116.11 via Sun Sep 2 06:40 - 06:40 (00:00) . . . . . . . .
iin the previous code can be any phrase in the previous table. I would like to apply a specific command e. g. begin new line when the code finds a specific string within the variable
i, for example when the variable
icontains a closed parenthesis
)I want the code to begin a new line.
When the code finishes reading the output of the command
last, I want the code to repeat the for loop once again (multiple times) to read if there are any new updates. How can I direct the code to re-run again? For example, is there such a command
gotowhich will force the code to go to specific line?
Would you please advice?