/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/languages/awk/awk

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# gawk -f <source> [input1] ... [inputn]
 
2
#############
 
3
# Main Idea #
 
4
############################################################################
 
5
#   The 'awk' utility reads the input files one line at a time.  For
 
6
# each line, 'awk' tries the patterns of each of the rules.  If several
 
7
# patterns match then several actions are run, in the order in which they
 
8
# appear in the 'awk' program.  If no patterns match, then no actions are
 
9
# run.
 
10
#############################################################################
 
11
# Exampler Paterns #
 
12
####################
 
13
/cgi/ {         # Pattern accepts if current string contains "cgi" substring
 
14
    $1 = "DL"   # You can modify input string
 
15
    print $0    # Prints current string
 
16
}
 
17
 
 
18
 
 
19
 
 
20
# This will be executed before processing files ( '{' Must been on some line )
 
21
BEGIN { 
 
22
    print "Welcome To Hell!"
 
23
}
 
24
 
 
25
# This will be executed after processing files ( '{' Must been on some line )
 
26
END {   
 
27
    print "Bye!"
 
28
}
 
29
 
 
30
 
 
31
# Example Function
 
32
function sum(a,b) {
 
33
    return a+b
 
34
}
 
35
# WARNING! Trying to supply function with RegExp parametr is dangerous, so
 
36
# func(/cgi/) will be translated as func($0 ~ /cgi/)