Lokesh (3054) Kushal (3053)
Lokesh (3054) Kushal (3053)
Lokesh (3054)
Kushal (3053)
WHAT IS AWK!!!
6
HANDLING TEXT
One major advantage of Awk is its ability to
handle strings as easily as many languages
handle numbers
BEGIN { print " Hello, world!" }
Some of the Built-In Variables
NF - Number of fields in current record
NR - Number of records read so far
$0 - Entire line
$n - Field n
$NF - Last field of current record
LIKE C LANGUAGE
IT HAS…..
OPERATORS
Operators in Increasing Precedence
Concatenation: blank
Add/Subtract: +, -
Multiply/divide/mod: *, /, %
Unary plus, minus, not, exponent (^ or **)
Increment, decrement
Field: $expr
String Concatenation
New strings can be created by combining old
ones
{ names = names $1 “ “ }
END { print names }
CONTINUE……
Arrays
Associative arrays (hash): index can be any value (integer or string)
Referencing creates entry: