Linux Shell Scripting Tutorial (LSST) v1.05r3 | ||
Chapter 7: awk Revisited | ||
|
awk utility is powerful data manipulation/scripting programming language (In fact based on the C programming Language). Use awk to handle complex task such as calculation, database handling, report creation etc.
General Syntax of awk:
Syntax:
awk -f {awk program file} filename
awk Program contains are something as follows:
Pattern {
action 1
action 2
action N
}
awk reads the input from given file (or from stdin also) one line at a time, then each line is compared with pattern. If pattern is match for each line then given action is taken. Pattern can be regular expressions. Following is the summery of common awk metacharacters:
Metacharacter | Meaning |
. (Dot) | Match any character |
* | Match zero or more character |
^ | Match beginning of line |
$ | Match end of line |
\ | Escape character following |
[ ] | List |
{ } | Match range of instance |
+ | Match one more preceding |
? | Match zero or one preceding |
| | Separate choices to match |
Converting lowercase character to uppercase | Getting Starting with awk |