Mercurial > docs > unix-phil
comparison unix-phil.ms @ 4:c707b0c5c849
new text about pipes
author | meillo@marmaro.de |
---|---|
date | Fri, 12 Feb 2010 19:30:13 +0100 |
parents | aebbe3e76f5e |
children | 48f1f3465550 |
comparison
equal
deleted
inserted
replaced
3:aebbe3e76f5e | 4:c707b0c5c849 |
---|---|
164 | 164 |
165 | 165 |
166 | 166 |
167 .NH 1 | 167 .NH 1 |
168 The Unix Philosophy | 168 The Unix Philosophy |
169 | 169 .LP |
170 .NH 2 | 170 The origins of the Unix Philosophy were already introduced. |
171 what it is | 171 This chapter explains the philosophy and shows concrete examples of its application. |
172 .LP | 172 .NH 2 |
173 definitions by McIlroy, Gancarz, ESR (maybe already in the intro) | 173 Examples |
174 .LP | 174 .LP |
175 cf. unix tool chain | 175 Following are some examples to demonstrate how applied Unix Philosophy feels like. |
176 .LP | 176 Knowledge of using the Unix shell is assumed. |
177 enabler pipe | 177 .PP |
178 Counting the number of files in the current directory: | |
179 .DS | |
180 .CW | |
181 ls | wc -l | |
182 .DE | |
183 The | |
184 .CW ls | |
185 command lists all files in the current directory, one per line, | |
186 and | |
187 .CW "wc -l | |
188 counts how many lines they are. | |
189 .PP | |
190 Counting all files that do not contain ``foo'' in their name: | |
191 .DS | |
192 .CW | |
193 ls | grep -v foo | wc -l | |
194 .DE | |
195 Here, the list of files is filtered by | |
196 .CW grep | |
197 to remove all that contain ``foo''. | |
198 The rest is the same as in the previous example. | |
199 .PP | |
200 Finding the five largest entries in the current directory. | |
201 .DS | |
202 .CW | |
203 du -s * | sort -nr | sed 5q | |
204 .DE | |
205 .CW "du -s * | |
206 returns the recursively summed sizes of all files | |
207 -- no matter if they are regular files or directories. | |
208 .CW "sort -nr | |
209 sorts the list numerically in reverse order. | |
210 Finally, | |
211 .CW "sed 5q | |
212 quits after it has printed the fifth line. | |
213 .PP | |
214 The presented command lines are examples of what Unix people would use | |
215 to get the desired output. | |
216 There are also other ways to get the same output. | |
217 It's a user's decision which way to go. | |
218 .NH 2 | |
219 Pipes | |
220 .LP | |
221 The examples show that a lot of tasks on a Unix system | |
222 are accomplished by combining several small programs. | |
223 The connection between the single programs is denoted by the pipe operator `|'. | |
224 .PP | |
225 Pipes, and their extensive and easy use, are one of the great | |
226 achievements of the Unix system. | |
227 Pipes between programs have been possible in earlier operating systems, | |
228 but it has never been a so central part of the concept. | |
229 When, in the early seventies, Doug McIlroy introduced pipes for the | |
230 Unix system, | |
231 ``it was this concept and notation for linking several programs together | |
232 that transformed Unix from a basic file-sharing system to an entirely new way of computing.'' | |
233 .[ | |
234 %T Unix: An Oral History | |
235 %O http://www.princeton.edu/~hos/frs122/unixhist/finalhis.htm | |
236 .] | |
237 .PP | |
238 Being able to specify pipelines in an easy way is, | |
239 however, not enough by itself. | |
240 It is only one part. | |
241 The other is the design of the programs that are used in the pipeline. | |
242 They have to be of an external shape that allows them to be be used in a pipeline. | |
243 | |
244 | |
178 | 245 |
179 .NH 2 | 246 .NH 2 |
180 Architecture | 247 Architecture |
181 .LP | 248 .LP |
182 the most important design decision. | 249 the most important design decision. |