Debian GNU/Linux : Guide to Installation and Usage by John Goerzen;Ossama Othman
page 103 of 298 (34%)
page 103 of 298 (34%)
![]() | ![]() |
|
There's a reason for the double functionality, however. For example, you
can connect the standard output of one command to the standard input of another. This is called a pipeline, and it uses the pipe operator6.1, |. Perhaps you want to see the GNU General Public License in reverse. To do this, you use the tac command (it's cat, only backward). Try it out: tac /usr/doc/copyright/GPL Unfortunately, it goes by too quickly to read. So you only get to see a couple of paragraphs. The solution is a pipeline: tac /usr/doc/copyright/GPL | less This takes the standard output of tac, which is the GPL in reverse, and sends it to the standard input of less. You can chain as many commands together as you like. Say you have an inexplicable desire to replace every G with Q. For this you use the command tr G Q, like this: tac /usr/doc/copyright/GPL | tr G Q | less You could get the same effect using temporary files and redirection, for example: tac /usr/doc/copyright/GPL > tmpfile tr G Q < tmpfile > tmpfile2 less < tmpfile2 rm tmpfile tmpfile2 |
|