Were there any programs or languages that already had these functions at the time you developed AWK?
Our original model was GREP. But GREP had a very limited form of pattern action processing, so we generalized the capabilities of GREP considerably. I was also interested at that time in string pattern matching algorithms and context-free grammar parsing algorithms for compiler applications. This means that you can see a certain similarity between what AWK does and what the compiler construction tools LEX and YACC do.
LEX and YACC were tools that were built around string pattern matching algorithms that I was working on: LEX was designed to do lexical analysis and YACC syntax analysis. These tools were compiler construction utilities which were widely used in Bell labs, and later elsewhere, to create all sorts of little languages. Brian Kernighan was using them to make languages for typesetting mathematics and picture processing.
LEX is a tool that looks for lexemes in input text. Lexemes are sequences of characters that make up logical units. For example, a keyword like 'then' in a programming language is a lexeme. The character 't' by itself isn't interesting, 'h' by itself isn't interesting, but the combination 'then' is interesting. One of the first tasks a compiler has to do is read the source program and group its characters into lexemes.
AWK was influenced by this kind of textual processing, but AWK was aimed at data-processing tasks and it assumed very little background on the part of the user in terms of programming sophistication.
Can you provide Computerworld readers with a brief summary in your own words of AWK as a language?
AWK is a language for processing files of text. A file is treated as a sequence of records, and by default each line is a record. Each line is broken up into a sequence of fields, so we can think of the first word in a line as the first field, the second word as the second field, and so on. An AWK program is of a sequence of pattern-action statements. AWK reads the input a line at a time. A line is scanned for each pattern in the program, and for each pattern that matches, the associated action is executed.
A simple example should make this clear. Suppose we have a file in which each line is a name followed by a phone number. Let's say the file contains the line 'Naomi 1234'. In the AWK program the first field is referred to as $1, the second field as $2, and so on Thus, we can create an AWK program to retrieve Naomi's phone number by simply writing $1 == "Naomi" {print $2} which means if the first field matches Naomi, then print the second field. Now you're an AWK programmer! If you typed that program into AWK and presented it with a file that had names and phone numbers that program, then it would print 1234 as Naomi's phone number.
A typical AWK program would have several pattern-action statements. The patterns can be Boolean combinations of strings and numbers; the actions can be statements in a C-like programming language.
AWK became popular since it was one of the standard programs that came with every UNIX system.
Latest on Shell Scripting
- Telstra revamps Windows Mobile, eyes cloud UC
- Review: Microsoft's System Center Virtual Machine Manager
- Glintech integrates Asterisk, Jabber for open source UC platform
- The A-Z of Programming Languages: BASH/Bourne-Again Shell
- The A-Z of Programming Languages: AWK
- Unix tip: Rescuing files from lost+found
- PowerShell Tips and Tricks
- Dynamic languages: More than just a quick fix
- Microsoft releases scripting tool for Vista
- Traveling Down the Unix $PATH
Development Essentials
- Top 10 wicked cool algorithms
- Facebook app verification fee draws criticism
- Microsoft's openness stressed
- Yahoo's developer platform to launch this week
- Microsoft starts new developer portal
- Google API allows creating apps that can track laptops
- PHP, JavaScript, Ruby, Perl, Python, and Tcl Today: The State of the Scripting Universe
- Analyst: In-house app development fraught with waste
- Is unit testing doomed?
- Open source still the best way to develop software
TechWorld Jobs (beta)
Recent Jobs
TechWorld Blogs
-

TalkingTech
The view from the top of IT with TechWorld Editor Rodney Gedda
-

Entrenched
Cooking up better code, IDG's developers reveal some of their secrets
-

Broadband Voice
Darren Pauli digs in from the front line of Australia's broadband battleground
Recent blog posts
- A Novell approach to business
- An open storage stack? I like the sound of that
- The mobile clone wars: fighting for a better phone experience
- Stopping the "Clean Feed"
- Identifying web platforms
- Clean Feed ‘not technically possible’
- No Clean Feed - well duh!
- Conroy's content cops still on the cards
- Will open source ruin the economy? Please help
- Linux kernel 2.6.27 is out!
Recent comments
- A real alternative?
16 hours 42 min ago - Hello this is Brianna
2 days 2 hours ago - Turn any PC into a media center
2 days 16 hours ago - How About the Correct Title?
3 days 7 hours ago - who are you kidding?
3 days 12 hours ago - Seriously, how much did they pay for this advertisement
5 days 3 hours ago - SF Bay Area - free Seminar on Enterprise Cloud Computing
5 days 6 hours ago - video conferening but not telepresence...
5 days 13 hours ago - SAMSUNG OLED 40" TECHNOLOGY
5 days 22 hours ago - What was the question again, oh well this was prepared earlier
1 week 1 day ago - Worldwide broadband prices continue to drop which means ? in AU
1 week 1 day ago - Not a Problem Here in Australia and New Zealand
1 week 3 days ago - Clear the air
1 week 4 days ago - Tabbed browsing, Quick Find,
1 week 6 days ago - Microsoft details plans for new social bookmarking tool
2 weeks 1 day ago - There is a 3rd party tool
2 weeks 2 days ago - Demise of Windows
2 weeks 3 days ago - new OS
2 weeks 3 days ago - Re: Favicon
2 weeks 4 days ago - Multi Camera Kino
2 weeks 4 days ago



