examples/demo_fieldwidths
raw| 1 | #!/usr/bin/env runawk |
| 2 | |
| 3 | #use "fieldwidths.awk" |
| 4 | |
| 5 | # This demo splits input lines into tokens according to FW variable |
| 6 | # that specifies the field widths. |
| 7 | |
| 8 | # Input files for this demo: examples/demo_fieldwidths.in* |
| 9 | |
| 10 | BEGIN { |
| 11 | FW = "4 5 6 2 1" |
| 12 | } |
| 13 | |
| 14 | { |
| 15 | print "NF=" NF |
| 16 | for (i=1; i <= NF; ++i){ |
| 17 | printf "$%d=%s\n", i, $i |
| 18 | } |
| 19 | } |