gawk: When
1
1 1.8 When to Use 'awk'
1 =====================
1
1 Now that you've seen some of what 'awk' can do, you might wonder how
1 'awk' could be useful for you. By using utility programs, advanced
1 patterns, field separators, arithmetic statements, and other selection
1 criteria, you can produce much more complex output. The 'awk' language
1 is very useful for producing reports from large amounts of raw data,
1 such as summarizing information from the output of other utility
1 programs like 'ls'. (⇒More Complex.)
1
1 Programs written with 'awk' are usually much smaller than they would
1 be in other languages. This makes 'awk' programs easy to compose and
1 use. Often, 'awk' programs can be quickly composed at your keyboard,
1 used once, and thrown away. Because 'awk' programs are interpreted, you
1 can avoid the (usually lengthy) compilation part of the typical
1 edit-compile-test-debug cycle of software development.
1
1 Complex programs have been written in 'awk', including a complete
1 retargetable assembler for eight-bit microprocessors (⇒Glossary,
1 for more information), and a microcode assembler for a special-purpose
1 Prolog computer. The original 'awk''s capabilities were strained by
1 tasks of such complexity, but modern versions are more capable.
1
1 If you find yourself writing 'awk' scripts of more than, say, a few
1 hundred lines, you might consider using a different programming
1 language. The shell is good at string and pattern matching; in
1 addition, it allows powerful use of the system utilities. Python offers
1 a nice balance between high-level ease of programming and access to
1 system facilities.(1)
1
1 ---------- Footnotes ----------
1
1 (1) Other popular scripting languages include Ruby and Perl.
1