docs/unix-phil

changeset 4:c707b0c5c849

new text about pipes
author meillo@marmaro.de
date Fri, 12 Feb 2010 19:30:13 +0100
parents aebbe3e76f5e
children 48f1f3465550
files unix-phil.ms
diffstat 1 files changed, 75 insertions(+), 8 deletions(-) [+]
line diff
     1.1 --- a/unix-phil.ms	Wed Feb 10 13:19:04 2010 +0100
     1.2 +++ b/unix-phil.ms	Fri Feb 12 19:30:13 2010 +0100
     1.3 @@ -166,15 +166,82 @@
     1.4  
     1.5  .NH 1
     1.6  The Unix Philosophy
     1.7 +.LP
     1.8 +The origins of the Unix Philosophy were already introduced.
     1.9 +This chapter explains the philosophy and shows concrete examples of its application.
    1.10 +.NH 2
    1.11 +Examples
    1.12 +.LP
    1.13 +Following are some examples to demonstrate how applied Unix Philosophy feels like.
    1.14 +Knowledge of using the Unix shell is assumed.
    1.15 +.PP
    1.16 +Counting the number of files in the current directory:
    1.17 +.DS
    1.18 +.CW
    1.19 +ls | wc -l
    1.20 +.DE
    1.21 +The
    1.22 +.CW ls
    1.23 +command lists all files in the current directory, one per line,
    1.24 +and
    1.25 +.CW "wc -l
    1.26 +counts how many lines they are.
    1.27 +.PP
    1.28 +Counting all files that do not contain ``foo'' in their name:
    1.29 +.DS
    1.30 +.CW
    1.31 +ls | grep -v foo | wc -l
    1.32 +.DE
    1.33 +Here, the list of files is filtered by
    1.34 +.CW grep
    1.35 +to remove all that contain ``foo''.
    1.36 +The rest is the same as in the previous example.
    1.37 +.PP
    1.38 +Finding the five largest entries in the current directory.
    1.39 +.DS
    1.40 +.CW
    1.41 +du -s * | sort -nr | sed 5q
    1.42 +.DE
    1.43 +.CW "du -s *
    1.44 +returns the recursively summed sizes of all files
    1.45 +-- no matter if they are regular files or directories.
    1.46 +.CW "sort -nr
    1.47 +sorts the list numerically in reverse order.
    1.48 +Finally,
    1.49 +.CW "sed 5q
    1.50 +quits after it has printed the fifth line.
    1.51 +.PP
    1.52 +The presented command lines are examples of what Unix people would use
    1.53 +to get the desired output.
    1.54 +There are also other ways to get the same output.
    1.55 +It's a user's decision which way to go.
    1.56 +.NH 2
    1.57 +Pipes
    1.58 +.LP
    1.59 +The examples show that a lot of tasks on a Unix system
    1.60 +are accomplished by combining several small programs.
    1.61 +The connection between the single programs is denoted by the pipe operator `|'.
    1.62 +.PP
    1.63 +Pipes, and their extensive and easy use, are one of the great
    1.64 +achievements of the Unix system.
    1.65 +Pipes between programs have been possible in earlier operating systems,
    1.66 +but it has never been a so central part of the concept.
    1.67 +When, in the early seventies, Doug McIlroy introduced pipes for the
    1.68 +Unix system,
    1.69 +``it was this concept and notation for linking several programs together
    1.70 +that transformed Unix from a basic file-sharing system to an entirely new way of computing.''
    1.71 +.[
    1.72 +%T Unix: An Oral History
    1.73 +%O http://www.princeton.edu/~hos/frs122/unixhist/finalhis.htm
    1.74 +.] 
    1.75 +.PP
    1.76 +Being able to specify pipelines in an easy way is,
    1.77 +however, not enough by itself.
    1.78 +It is only one part.
    1.79 +The other is the design of the programs that are used in the pipeline.
    1.80 +They have to be of an external shape that allows them to be be used in a pipeline.
    1.81  
    1.82 -.NH 2
    1.83 -what it is
    1.84 -.LP
    1.85 -definitions by McIlroy, Gancarz, ESR (maybe already in the intro)
    1.86 -.LP
    1.87 -cf. unix tool chain
    1.88 -.LP
    1.89 -enabler pipe
    1.90 +
    1.91  
    1.92  .NH 2
    1.93  Architecture