Enjoy fast, free delivery, exclusive deals, and award-winning movies & TV shows with Prime
Try Prime
and start saving today with fast, free delivery
Amazon Prime includes:
Fast, FREE Delivery is available to Prime members. To join, select "Try Amazon Prime and start saving today with Fast, FREE Delivery" below the Add to Cart button.
Amazon Prime members enjoy:- Cardmembers earn 5% Back at Amazon.com with a Prime Credit Card.
- Unlimited Free Two-Day Delivery
- Streaming of thousands of movies and TV shows with limited ads on Prime Video.
- A Kindle book to borrow for free each month - with no due dates
- Listen to over 2 million songs and hundreds of playlists
- Unlimited photo storage with anywhere access
Important: Your credit card will NOT be charged when you start your free trial or if you cancel during the trial period. If you're happy with Amazon Prime, do nothing. At the end of the free trial, your membership will automatically upgrade to a monthly membership.
Buy new:
-80% $30.84$30.84
Ships from: Amazon Sold by: ReelBrand
Save with Used - Good
$10.99$10.99
Ships from: Amazon Sold by: THREE BROTHERS ONLINE SALES INC
Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
The AWK Programming Language 1st Edition
There is a newer edition of this item:
Purchase options and add-ons
- ISBN-10020107981X
- ISBN-13978-0201079814
- Edition1st
- PublisherPearson
- Publication dateJanuary 11, 1988
- LanguageEnglish
- Dimensions9.22 x 6.26 x 0.44 inches
- Print length224 pages
Frequently bought together

Similar items that ship from close to you
Editorial Reviews
From the Back Cover
Originally developed by Alfred Aho, Brian Kernighan, and Peter Weinberger in 1977, AWK is a pattern-matching language for writing short programs to perform common data-manipulation tasks. In 1985, a new version of the language was developed, incorporating additional features such as multiple input files, dynamic regular expressions, and user-defined functions. This new version is available for both Unix and MS-DOS.
This is the first book on AWK. It begins with a tutorial that shows how easy AWK is to use. The tutorial is followed by a comprehensive manual for the new version of AWK. Subsequent chapters illustrate the language by a range of useful applications, such as:
- Retrieving, transforming, reducing, and validating data
- Managing small, personal databases
- Text processing
- Little languages
- Experimenting with algorithms
020107981XB04062001
About the Author
Brian W. Kernighan works in the Computing Science Research Center at Bell Laboratories, Lucent Technologies. He is Consulting Editor for Addison-Wesley's Professional Computing Series and the author, with Dennis Ritchie, of The C Programming Language.
020107981XAB04062001
Excerpt. © Reprinted by permission. All rights reserved.
Computer users spend a lot of time doing simple mechanical data manipulation -- changing the format of data, checking its validity, finding items with some property, adding up numbers, printing reports, and the like. All of these jobs ought to be mechanized, but it's a real nuisance to have to write a special-purpose program in a standard language like C or Pascal each time such a task comes up.
Awk is a programming language that makes it possible to handle such tasks with very short programs, often only one or two lines long. An awk program is a sequence of patterns and actions that tell what to look for in the input data and what to do when it's found. Awk searches a set of files for lines matched by any of the patterns; when a matching line is found, the corresponding action is performed. A pattern can select lines by combinations of regular expressions and comparison operations on strings, numbers, fields, variables, and array elements. Actions may perform arbutrary processing on selected lines,; the action language looks like C but there are no declarations, and strings and numbers are built-in data types.
Awk scans the input files and splits each input line into fields automatically. Because so many things are automatic--input, field splitting, storage management, initialization--awk programs are usually much smaller than they would be in a more conventional language. Thus one common use of awk is for the kind of data manipulation suggested above. Programs, a line or two long, are composed at the keyboard, run once, then discarded. In effect, awk is a general-purpose programable tool that can replace a host of specialized tools or programs.
The same brevity of expression and convenience of operations make awk valuable for prototyping larger programs. One starts with a few lines, then refines the program unitil it doesth edesired job, experimenting with designs by trying alternatives quickly. Since programs are short, it's easy to get started, and easy to start over when experience suggests a different direction. And, it's straightforward to translate an awk program into another language once the design is right.
Organization of the Book
The first goal of this book is to teach you what awk is and how to use it effectively. Chapter 1 is a tutorial on the bare minimum necessary to get started; after reading even a few pages you should have enough information to begin writing useful programs. The examples in this chapter are very short and simple, typical othe interactive use of awk.
Chapter 2 covers the entire language in a systematic order. Although there are plenty of examples in this chapter, like most manuals it's long and a bit dry, so you will probably want to skim it on a first reading.
The rest of the book contains a wide variety of examples, chosen to show the breadth of applicability of awk and how to make good use of its facilities. Some of the programs are in regular use in our environment; others show ideas but are not intended for production use; a few are included just because they are fun.
The emphasis in Chapter 3 is on retrieval, transformation, reduction and validation of data--the tasks that awk was originally designed for. There is also a discussion of how to handle data like address lists that naturally comes in multiline chunks.
Awk is a good language for managing small, personal databases. Chapter 4 discusses the generation of reports from databases, and builds a simple relational database system and query language for data stored in multiple files.
Awk handles text with much the same convenience that most languages handle numbers, so it often finds application in text processing. Chapter 5 describes programs for generating text, and some that help with document preparation. One of the examples is an indexing program based on the one we used for this book.
Chapter 6 is about "little languages," that is, specialized languages that focus on a narrow domain. Awk is convenient for writing small translators because it's basic operations support many of the lexical and table- management tasks encountered in translation. The chapter includes an assembler, a graphics language, and several calculators.
Awk is a good language for expressing certain kinds of algorithms. Because there are no declarations and because storage management is easy, an awk program has many of the advantages of pseudo-code but awk programs can be run, which is not true of pseudo-code. The focus in Chapter 7 is on experimentation with algorithms, including testing and performance evaluation. It shows several sorting algorithms, and culminates in a version of the Unix make program.
Chapter 8 describes some of the historical reasons why awk is as it is and offers some suggestions on what to do when it is too slow or too confining.
Appendix A is a summary of the language; Appendix B contains answers to selected exercises.
You shoul begin by reading Chapter 1, and trying some small examples of your own. Go through Chapter 2 quickly, concentrating on the summaries and tables; don't get bogged down in the details. Then read as far into each of the subsequent chapters as your interest takes you. These chapters are nearly independent of each other, so the order doesn't matter much.
The Examples
There are several themes in the examples. The primary one, of course, is to show how to use awk well. We have tried to include a wide variety of useful constructions, and we have stressed particular aspects like associative arrays and regular expressions that typify awk programming.
A second theme is to show awk's versatility. Awk programs have been used from databades to circuit design, from numerical analysis to graphics, from compilers to system adminstration, from a first language for nonprogrammers to the implementation language for software engineering courses. We hope that the diversity of applications illustrated in the book will suggest new possibilities to you as well.
A third theme is to show how common computing operations are done. The book contains a relational database system, an assembler and interpreter for a toy computer, a graph-drawing language, a recursive-descent parser for an awk subset, a file-update program based on make and many other examples. In each case, a short awk program conveys the essence of how something works in a form that you can understand and play with.
We have also tried to illustrate a spectrum of ways to attack programming problems. Rapid prototyping is an approach that awk supports well. A less obvious strategy is divide and conquer; breaking a big job into small components, each concentrating on one aspect of the problem. Another is writing programs that create other programs. Little languages define a good user interface and often suggest a sound implementation. Although these ideas are presented here in the context of awk, they are much more generally applicable and ought to part of every programmer's repertoire.
The examples have all been tested directly from the text, which is in machine-readable form. We have tried to make the programs error-free, but we have not added features nor made them proof against all possible invalid inputs, preferring to concentrate on conveying the essentials.
Evolution of the AWK language
Awk was originally designed and implemented by the authors in 1977, in part as an experiment to see how the Unix gools grep and sed could be generalized to deal with numbers as well as text. It was based on our interests in regular expressions and programmable editors. Although it was meant for writing very short programs, its combination of facilities soon attracted users who wrote significantly larger programs. These larger programs needed features that had not been part of the original implementation, so awk was enhanced in a new version made available in 1985.
Other enhancements include dynamic regular expressions, with text substitution and pattern-matching functions; additional built-in functions and variables; some new operators and statements; iput from multiple files; and access to command-line arguments. Error messages have also been improved. The examples in Chapter 1 use only facilities of the original version; many examples in later chapters take advantage of new features.
The version of awk is partof Unix System V Release 3.1. Source code for this version is also available through AT&T's Unix System Toolchest software distribution system; call 1-201-522-6900 and log in as guest. In Europe, contact AT&T Unix Europe in London (44-1-567-7711); in the Far EASt, contact AT&T Unix Pacific in Tokyo (81-3-431-3670).
Since awk was developed under Unix, some of its features reflect capabilities usually found only there; these features are used in some of our examples. Furthermore, we have assumed the existence of some Unix utilities, particularly sort, for which exact equivalents may not exist elsewhere. Aside from these limitations, however, awk should be useful in any environment; in particular, it runs on MS-DOS. Further information is available from Addison-Wesley.
Awk is certainly not perfect; it has its share of irregularities, omissions, and just plain bad ideas, and it's sometimes painfully slow. But it's also a rich and versatile language, useful in a remarkable number of cases. We hope you'll find it as valuable as we do.
Acknowledgments
We are deeply indebted to friends who made comments and suggestions on drafts of this book. We are particularly grateful to Jon Bentley, whose enthusiasm has been an inspiration for years. Jon contributed many ideas and programs derived from his experience using and teaching awk; he also read several drafts with great care. Doug McIlroy also deserves special recognition; his peerless talent as a reader greatly improved the structure and content of the whole book. Others who made helpful comments on the manuscript include Susan Aho, Jaap Akkerhuis, Lorinda Cherry, Chris Fraser, Eric Grosse, Ricardo Gusella, Bob Herbst, Mark Kernighan, John Linderman, Bob Martin, Howard Moscovitz, Gerard Schmitt, Don Swartwout, Howard Trickey, Peter van Eijk, Chris Van Wyk, and Mihalis Yannakakis. We thank them all.
Alfred V. Aho
Brian W. Kernighan
Peter J. Weinberger
020107981XP04062001
Product details
- Publisher : Pearson; 1st edition (January 11, 1988)
- Language : English
- Paperback : 224 pages
- ISBN-10 : 020107981X
- ISBN-13 : 978-0201079814
- Item Weight : 10.4 ounces
- Dimensions : 9.22 x 6.26 x 0.44 inches
- Best Sellers Rank: #589,878 in Books (See Top 100 in Books)
- #367 in Computer Programming Languages
- #1,551 in Programming Languages (Books)
- #1,659 in Computer Software (Books)
- Customer Reviews:
About the authors

Alfred Vaino Aho (born August 9, 1941) is a Canadian computer scientist best known for his work on programming languages, compilers, and related algorithms, and his textbooks on the art and science of computer programming.
Bio from Wikipedia, the free encyclopedia.

Discover more of the author’s books, see similar authors, read book recommendations and more.

Discover more of the author’s books, see similar authors, read book recommendations and more.
Customer reviews
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Learn more how customers reviews work on AmazonCustomers say
Customers find the book excellent for learning AWK. They say it offers something to novices and advanced users. Readers appreciate the clear, easy-to-understand writing. They mention the book is concise and to the point, with no unnecessary words.
AI-generated from the text of customer reviews
Customers find the book excellent for learning AWK. They say it offers something to novices and advanced users, and is well-written. Readers also mention the book is concise, has clear, concise headings, and examples. In addition, they say it teaches other computing concepts not only on AWK.
"...show its power in various applications, and also serve as tutorials on some programming topics such as sorting and parsing...." Read more
"...I used to own a copy of this book. It's great, and if you're interested in awk you should definitely seek out a USED copy...." Read more
"Small book ~200pp paperback 6x8 or so, many examples, including a (Theory of Programming) example; build an assembler and interpreter in AWK and..." Read more
"...And this book is perhaps the best way to learn the language." Read more
Customers find the book concise, accurate, and easy to understand. They appreciate the lack of wordiness. Readers also mention it provides an easy, stress-free introduction to computer programs.
"...programming manual is available freely as a PDF online and is also well-written...." Read more
"...Plus a lot of simple short one line regular expression examples...." Read more
"As another recent review stated, the first two paragraphs are well written and to the point...." Read more
"Great! Author writes in a way that is easy to understand. Even for the section on regex...." Read more
Reviews with images
Impeccable Condition
-
Top reviews
Top reviews from the United States
There was a problem filtering reviews right now. Please try again later.
The book starts with a tutorial chapter, then chapter 2 describes the language fairly completely. The remaining chapters show its power in various applications, and also serve as tutorials on some programming topics such as sorting and parsing.
Keep in mind that this is the original version of the language. Most Linux systems now use gawk (GNU awk) which includes many features not in the version described here. The gawk programming manual is available freely as a PDF online and is also well-written. The POSIX specification of awk (also available online) was based on the version described in this book.
There are errata for this book available online you can find pretty easily with a web search; it’s a pretty short list, only about a half a page. I found an error not in the list: on page 46, the example for grouping shows ($i)++ described as “add 1 to value of the i-th field”. This is wrong, and would be bad example even if it worked. I emailed Mr. Kernighan and he acknowledged the error, suggesting there may be a second edition some day.
I got a used copy for about $23 and it’s in pretty good condition, clean but with a couple very slight bends in the spine, and the pages are slightly yellowed with age (an October 1988 printing). I am curious about what a new printing looks like, but not willing to spend $89.75 to find out. The one I have is Addison-Wesley. I don’t know how they deal with reprints of old computer books. I have seen what Prentice-Hall has done with some classic computer books; they look to be cheaply printed from photocopies, with blurry text and high prices. I hope A-W does better.
I used to own a copy of this book. It's great, and if you're interested in awk you should definitely seek out a USED copy. That said, this is not the end-all-be-all awk reference. Depending on the awk that you're using (more than one flavor exists) this book may actually disappoint you.
Take gawk, for example: it has socket networking, column-based fields, and other bells and whistles that aren't covered in this book. I believe nawk also has features not covered or even acknowledged. So while I agree that this is A great awk book, it is far from being THE great awk book. From my own personal experience with awk, no such book exists. I can't imagine fully embracing awk with less than two decent references. They're all kinda small so two books shouldn't scare you.
My personal opinion: buy a copy of this book in some form and at least get an O'Reilly awk book (sed & awk is a good one), and if you want to go wild with gawk (my favorite), the gawk manual is indispensable.
Or, just learn from websites. There's a ton of info out there ripe for the pickin'.
Many O'Reilly writers can take a good writing tip from the structure of this book!
Reading only two paragraphs, an AWK programmer can easily write intermediate level AWK scripts.
Pros
1) Written to the point, containing only facts, with no unnecessary words!
2) Due to a lack of wordiness, the book is a short read.
Cons
1) I'm still a fan of O'Reilly books being open, or containing no Digital Rights Management. (ie. DRM, Encryption, ...)
2) Cut and dry, similar to Kernighan's, The C Programming Language, but a much shorter read.
3) No PDF or EBook version.
Top reviews from other countries
Reviewed in Spain on September 11, 2019
Pour ma part, la seule lecture attentive du premier chapitre m'a ouvert les yeux sur cet outil très puissant que je n'utilisais que de manière très sommaire auparavant.








