As usual, lots of ways to do this...
command example might deserve a little closer look because it's an unusual strategy (well, not for Unix)...
In the Unix world, many programs act as filters
which take some input-stream, do something to it, and write the results to an output-stream. The output-stream of one filter is often piped to
another filter, becoming its input-stream. Piping is indicated by the '|' character.
In the code:
tr -d '\r' < inputfile | tr -d '\n' > outputfile
we have two instances of the tr
filtering-command, separated by a pipe. So we're actually going to have two instances of the tr command
running at the same time, one feeding its output as input to the other.
The first part:
tr -d '\r' < inputfile
uses the '<' operator to specify that inputfile
(whatever file that is) is to be used as the input. The command writes its modified output to its standard-output stream, where it's piped to become the input to the second tr
tr -d '\n' > outputfile
... which uses the '>' operator to specify its output-file.
So this approach solves the problem in a very Unix-like way: by running two small, generalized programs and piping them together to solve a problem.