# HG changeset patch # User meillo@marmaro.de # Date 1265999413 -3600 # Node ID c707b0c5c8491ca09e6e593ee26c8f6fdf1a8e63 # Parent aebbe3e76f5eb2863fc954c058c46df3d5a7a232 new text about pipes diff -r aebbe3e76f5e -r c707b0c5c849 unix-phil.ms --- a/unix-phil.ms Wed Feb 10 13:19:04 2010 +0100 +++ b/unix-phil.ms Fri Feb 12 19:30:13 2010 +0100 @@ -166,15 +166,82 @@ .NH 1 The Unix Philosophy +.LP +The origins of the Unix Philosophy were already introduced. +This chapter explains the philosophy and shows concrete examples of its application. +.NH 2 +Examples +.LP +Following are some examples to demonstrate how applied Unix Philosophy feels like. +Knowledge of using the Unix shell is assumed. +.PP +Counting the number of files in the current directory: +.DS +.CW +ls | wc -l +.DE +The +.CW ls +command lists all files in the current directory, one per line, +and +.CW "wc -l +counts how many lines they are. +.PP +Counting all files that do not contain ``foo'' in their name: +.DS +.CW +ls | grep -v foo | wc -l +.DE +Here, the list of files is filtered by +.CW grep +to remove all that contain ``foo''. +The rest is the same as in the previous example. +.PP +Finding the five largest entries in the current directory. +.DS +.CW +du -s * | sort -nr | sed 5q +.DE +.CW "du -s * +returns the recursively summed sizes of all files +-- no matter if they are regular files or directories. +.CW "sort -nr +sorts the list numerically in reverse order. +Finally, +.CW "sed 5q +quits after it has printed the fifth line. +.PP +The presented command lines are examples of what Unix people would use +to get the desired output. +There are also other ways to get the same output. +It's a user's decision which way to go. +.NH 2 +Pipes +.LP +The examples show that a lot of tasks on a Unix system +are accomplished by combining several small programs. +The connection between the single programs is denoted by the pipe operator `|'. +.PP +Pipes, and their extensive and easy use, are one of the great +achievements of the Unix system. +Pipes between programs have been possible in earlier operating systems, +but it has never been a so central part of the concept. +When, in the early seventies, Doug McIlroy introduced pipes for the +Unix system, +``it was this concept and notation for linking several programs together +that transformed Unix from a basic file-sharing system to an entirely new way of computing.'' +.[ +%T Unix: An Oral History +%O http://www.princeton.edu/~hos/frs122/unixhist/finalhis.htm +.] +.PP +Being able to specify pipelines in an easy way is, +however, not enough by itself. +It is only one part. +The other is the design of the programs that are used in the pipeline. +They have to be of an external shape that allows them to be be used in a pipeline. -.NH 2 -what it is -.LP -definitions by McIlroy, Gancarz, ESR (maybe already in the intro) -.LP -cf. unix tool chain -.LP -enabler pipe + .NH 2 Architecture