The standard input is expecting a data stream from the keyboard. But the input can be redirected from a file instead. This is done by using the redirection symbol < in Linux. We demonstrate this by using the same script as previously, but now a data file, intest.txt, provides the script with data; see Figure 17.5:
No modification in the script itself is required. It can be used in either way.
The same holds for outputs. By default the output is displayed in the terminal, but also here there is the option to redirect the output to a file. In that case, the redirect symbol is >; see Figure 17.6:
Now, a file with the name result.txt is created and the output of the script is written to it. If there was already a file with this name, its content is overwritten. If instead the output should be appended to an already-existing...