File: template_extract.awk

package info (click to toggle)
localechooser 2.69
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,608 kB
  • ctags: 14
  • sloc: sh: 1,096; perl: 187; makefile: 71; awk: 42
file content (33 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# AWK-script to extract specific template from templates file

# The script takes three parameters:
# - TEMPLATE: The template to be extracted from the templatefile
# - TFILE1: The extracted template will be written here
# - TFILE2: All other templates will be written here (can be /dev/null ;-)

BEGIN {
    FOUND = 0
    TEMPLATE = "Template: " TEMPLATE
}

{
    line=$0

    if (index(line, TEMPLATE) > 0) {
        FOUND = 1
        print line >>TFILE1
        getline
        line=$0
    }

    if (FOUND == 1) {
        if (substr(line, 1, 9) == "Template:") {
            FOUND = 0
            print line >>TFILE2
        } else {
            print line >>TFILE1
        }
    } else {
        print line >>TFILE2
    }
}