Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Get started with GAWK: AWK language fundamentals

Begin learning AWK with the open source GAWK implementation

Michael Stutz, Author, Freelance Developer
Michael Stutz is author of The Linux Cookbook , which he also designed and typeset using only open source software. His research interests include digital publishing and the future of the book. He has used various UNIX operating systems for 20 years. You can reach him at stutz@dsl.org.

Summary:  Discover the basic concepts of the AWK text-processing and pattern-scanning language. This tutorial gets you started programming in AWK: You'll learn how AWK reads and sorts its input data, run AWK programs, manipulate data, and perform complex pattern matching. When you're finished, you'll also understand GNU AWK (GAWK).

Date:  19 Sep 2006
Level:  Intermediate PDF:  A4 and Letter (109 KB | 24 pages)Get Adobe® Reader®

Activity:  17848 views
Comments:  

Before you start

Learn what to expect from this tutorial, how to get the most out of it, and what you need to work through it.

About this tutorial

GNU AWK (GAWK) is an open source implementation of the venerable AWK programming language and it is available for all UNIX® systems. The AWK language is a UNIX standby -- a powerful text-manipulation and pattern-matching language that is particularly suited for information retrieval, making it ideal for use with today's database-driven applications. Because of its integration with the UNIX environment, complete working programs can be conceived, built, and executed quickly, with immediate results.

This tutorial provides a hands-on introduction to the AWK text-processing language. It shows how to use the open source GAWK interpreter to write and execute AWK programs so that you can search and manipulate your data in various ways.


Objectives

This tutorial is written for anyone who wants to begin harnessing the text-manipulation power of AWK. In this tutorial, you use GAWK to learn the various methods of running AWK programs. You also see how programs are structured and learn AWK's record and field paradigm. By the time you have completed the tutorial, you will have learned the rudimentary aspects of the language, including formatting output, record and field manipulation, and pattern matching. You should also be able to write custom AWK programs to perform complex text processing from the UNIX command line.


Prerequisites

This tutorial has no particular prerequisites, although you should be familiar with using a UNIX command-line shell. Some familiarity with the constructs of the C programming language is helpful, but it is not required.


System requirements

You must have a working copy of GAWK installed on your system, preferably Version 3.0 or later. GAWK is easily obtainable in both source and binary packages (see Resources). If you're installing GAWK from source, consult the README file in the GAWK source distribution, which lists any additional software requirements for successful compilation and installation.

1 of 9 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX
ArticleID=160836
TutorialTitle=Get started with GAWK: AWK language fundamentals
publish-date=09192006
author1-email=stutz@dsl.org
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers