source: project/awk/awk.html @ 1

Last change on this file since 1 was 1, checked in by azul, 14 years ago

Import everything.

File size: 1.8 KB
Line 
1<html>
2<head><title>Eggs Unlimited - awk</title></head>
3<body>
4
5<center><img src="egg.jpg"></center>
6<center><a href="index.html">back</a></center>
7
8<h2>awk</h2>
9
10<h3>Description:</h3>
11A looping construct for processing input in a way similar to
12the <b>awk</b> tool.
13
14<h3>Author:</h3>
15Originally by Olin Shivers. This implementation has been taken from
16<a href="http://www.plt-scheme.org">PLT</a> and minimally modified by
17<a href="mailto:felix@call-with-current-continuation.org">felix</a>
18to work with Chicken.
19
20<h3>Version:</h3>
21<ul>
22<li>1.1
23Adapted to new setup scheme
24<li>1.0
25</ul>
26
27<h3>Usage:</h3> 
28<pre>
29(require-extension awk)
30</pre>
31
32<h3>Download:</h3>
33<a href="awk.egg">awk.egg</a>
34
35<h3>Documentation:</h3>
36See <a href="http://www.scsh.net/docu/html/man-Z-H-9.html#%_sec_8.2">the SCSH
37documentation for <code><b>awk</b></code></a>.
38
39<p><h3>Examples:</h3>
40<pre>
41--- Count non-comment lines in Scheme file:
42(print
43 (awk (read-line) (line) ([nlines 0])
44   ("^[ \t]*;" nlines)
45   (else (add1 nlines)) ) )
46
47--- Strip blank lines:
48(awk (read-line) (line) ()
49  ("[^ \t]" (print line)) )
50
51--- Compute maximal line length:
52(print
53  (awk (read-line) (line) ([max-len 0])
54    (#t (max max-len (string-length line))) ) )
55
56--- Sort /etc/passwd file:
57(define (read-passwd . port)
58  (let ([line (apply read-line port)])
59    (if (eof-object? line)
60        (values line #f)
61        (values line (string-split-fields ":" line #:infix)) ) ) )
62
63(for-each
64 (lambda (entry) (print (cdr entry)))
65 (sort
66  (awk (read-passwd) (line fields) ([ans '()])
67    (#t (cons (cons (car fields) line) ans)) )
68  (lambda (x y) (string&lt;? (car x) (car y))) ) ) )
69</pre>
70
71<h3>License:</h3>
72
73PLT Software
74Copyright (c) 1995-2002 PLT
75
76PLT software is distributed under the GNU Lesser General Public
77License (LGPL).
78
79<hr>
80<a href="index.html">back</a>
81
82</body>
83</html>
Note: See TracBrowser for help on using the repository browser.