awk

awk (also written as Awk and AWK) is a utility that enables a programmer to write tiny but effective programs in the form of statements that define text patterns that are to be searched for in each line of a document and the action that is to be taken when a match is found within a line.

awk (also written as Awk and AWK) is a utility that enables a programmer to write tiny but effective programs in the form of statements that define text patterns that are to be searched for in each line of a document and the action that is to be taken when a match is found within a line. awk comes with most UNIX-based operating systems such as Linux, and also with some other operating systems, such as Windows 95/98/NT.

An awk program is made up of patterns and actions to be performed when a pattern match is found. awk scans input lines sequentially and examines each one to determine whether it contains a pattern matching one specified by the user. When the matching pattern is found, awk carries out the instructions in the program. For example, awk could scan text for a critical portion and reformat the text contained in it according to the user's command. If no pattern is specified, the program will carry out the command on all of the input data.

awk breaks each line into fields, which are groups of characters with spaces acting as separators so that a word, for example, would be a field. A string is encased in backslashes and actions to be performed are encased in curly brackets. The lines are numbered in order of their appearance, with "0" refering to the entire line. "$" is the symbol for field. So, for example, to search for a line containing the word "nutmeg," and to print each line in which the word occurs, the awk program would consist of:

/nutmeg/ { print $0 }.

The name "awk" is derived from the names of its three developers: Alfred Aho, Peter Weinberger, and Brian Kernighan. It was developed from grep, C, and sed syntax, a combination that allows complex programs to be developed quickly. awk is frequently used for prototyping. Versions of awk include Portable Operating System Interface awk, New awk (Nawk) and GNU awk (Gawk). The Practical Extraction and Reporting Language language was developed as an improved version of awk, with which Perl is backward compatible. (als

This was first published in April 2005

Glossary

'awk' is part of the:

View All Definitions

Dig deeper on SOA, XML and Web Services Development Tools

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

File Extensions and File Formats

Powered by:

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close