File: demo_tokenre

package info (click to toggle)
runawk 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: awk: 1,127; ansic: 736; sh: 420; makefile: 103
file content (23 lines) | stat: -rwxr-xr-x 442 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env runawk

#use "tokenre.awk"

# This demo splits input line into tokens according to regexp that
# defines a token, not <space> between tokens.
#
# Suported tokens:
#   - sequence of non-space and not " characters
#   - "la-la-la even spaces here   "

# Input files for this demo: examples/demo_tokenre.in*

BEGIN {
	TRE="\"[^\"]*\"|[^\"[:space:]]+"
}

{
	print "NF=" NF
	for (i=1; i <= NF; ++i){
		printf "$%d=%s\n", i, $i
	}
}