Lecture9

Lecture9 - Lecture 9 Introduction to AWK COP 3344...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 9 Introduction to AWK COP 3344 Introduction to UNIX 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is AWK • Important early text manipulation language – Created by Al Aho, Peter Weinberger & Brian Kernighan • This Unix utility manipulates text files that are viewed as arranged in columns 2 • awk splits each line of input (from standard input or a set of files) based on whitespace (the default) and processes each line - the field separator need not be whitespace but can also be a specified character • There are also other flavors of awk such as nawk and gawk
Background image of page 2
Awk Command Structure awk [options] ‘program’ [file(s)] awk [options] -f programfile [files(s)] • A program can be one or more pairs of the following: pattern { procedure } 3 • BEGIN and END constructs can also be used • An important option is -Fc where c is the field separator to use. For example awk -F: . . . indicates that the separator is”:” • Example awk -F: ‘/this/ { print $2 }’ file1
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Awk Program Processing • awk scans each input line for pattern and when a match occur the associated actions defined by procedure are executed. The general form of a program is: BEGIN { initial statements }
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/23/2008 for the course COP 3344 taught by Professor Sudhir during the Spring '08 term at FSU.

Page1 / 11

Lecture9 - Lecture 9 Introduction to AWK COP 3344...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online