| Date: Tue, 23 Jul 2002 09:44:28 +0200
| From: David Neary <dneary at wanadoo.fr>
|
| Paul Jakma wrote:
| > > Personally, I think they are demented. It's much more a job for
| > > something simple like Sed or Awk.
| >
| > ah.. no. sed - you'll only substitute stuff, not powerful enough.
| > awk doesnt have the data structures. i've looked.
|
| You can only substitute stuff in sed? As someone who uses it quite
| a bit for other stuff, because I'm lazy, I'd have to disagree.
the "awk doesn't have data structures" is not exactly correct
either, albeit like the sed(1) claim, it's not entirely wrong
either (making a distinction between common usage and what is
actually possible / done by some).
awk(1) --- esp. the new awk, `nawk' ("new" is a relative term
as `nawk' is c.15(?) years old by now, and most `awk's are of
the "new" form, including GNU awk, gawk(1)) --- can structure
data, albeit in a slightly sideways form: associative arrays
(esp. multi-dimensional arrays).
e.g., a C/C++ like data structure:
struct Foo {
int a;
int b;
char* s;
} key;
can be approximated in several ways. one possibility is:
Foo[key,"a"] # struct Foo key; key.a ...
Foo[key,"b"] # struct Foo key; key.b ...
...
another is:
key["Foo","a"] # struct Foo key; key.a ...
another is:
Foo[key] = a SUBSEP b SUBSEP s
and there are yet other variations. season as to taste.
it is the new awk which is described in a classic reference
which should be on everyone's bookshelf:
Alfred V Aho, Brian W Kernighan, and Peter J Weinberger,
«The AWK Programming Lanuguage»,
1988, Addison-Wesley, ISBN 0-201-07981-X.
you should recognize the authors of the book as being the
`A', `K', and `W' of `awk' ....
cheers!
-blf-
--
Innovative, very experienced, Unix and | Brian Foster Dublin, Ireland
Chorus (embedded RTOS) kernel internals | e-mail: blf at utvinternet.ie
expert looking for a new position ... | mobile: (+353 or 0)86 854 9268
For a résumé, contact me, or see my website http://www.blf.utvinternet.ie
Stop E$$o (ExxonMobile): «Whatever you do, don't buy Esso --- they
don't give a damn about global warming.» http://www.stopesso.com
Supported by Greenpeace, Friends of the Earth, and numerous others...
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!