GNU Info

Info Node: (gawk.info)When

(gawk.info)When


Prev: Other Features Up: Getting Started
Enter node , (file) or (file)node

When to Use `awk'
=================

   Now that you've seen some of what `awk' can do, you might wonder how
`awk' could be useful for you.  By using utility programs, advanced
patterns, field separators, arithmetic statements, and other selection
criteria, you can produce much more complex output.  The `awk' language
is very useful for producing reports from large amounts of raw data,
such as summarizing information from the output of other utility
programs like `ls'.  (Note: A More Complex Example.)

   Programs written with `awk' are usually much smaller than they would
be in other languages.  This makes `awk' programs easy to compose and
use.  Often, `awk' programs can be quickly composed at your terminal,
used once, and thrown away.  Because `awk' programs are interpreted, you
can avoid the (usually lengthy) compilation part of the typical
edit-compile-test-debug cycle of software development.

   Complex programs have been written in `awk', including a complete
retargetable assembler for eight-bit microprocessors (Note: Glossary,
for more information), and a microcode assembler for a special purpose
Prolog computer.  However, `awk''s capabilities are strained by tasks of
such complexity.

   If you find yourself writing `awk' scripts of more than, say, a few
hundred lines, you might consider using a different programming
language.  Emacs Lisp is a good choice if you need sophisticated string
or pattern matching capabilities.  The shell is also good at string and
pattern matching; in addition, it allows powerful use of the system
utilities.  More conventional languages, such as C, C++, and Java, offer
better facilities for system programming and for managing the complexity
of large programs.  Programs in these languages may require more lines
of source code than the equivalent `awk' programs, but they are easier
to maintain and usually run more efficiently.


automatically generated by info2www version 1.2.2.9