CHAPTER 27Read Piped Input
Many programs available to the UNIX or Linux operating systems have the ability to process input from standard input through a pipe, Similarly, the following short script demonstrates how to perform this task using a shell script. The script also demonstrates a number of interesting techniques that are covered in more depth elsewhere in this book.
The purpose of the script is to take its input, whether from a file or stdin, and print the data to stdout in reverse order. The script provides two ways to perform this task. The first method works by calling the script with an argument that is the name of the file to be reversed. Alternatively, you can pipe output from some other command into the script, and it will then ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access