xref: /freebsd/contrib/one-true-awk/testdir/tt.big (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1{ print }
2{ print NR, NF, $0 }
3{ $2 = length($2); print }
4{ s += length($2) }
5END { print s }
6{ s += $3 }
7END { print s }
8{ for (i = NF; i > 0; i--)
9	printf "%s ", $i
10  printf("\n")
11}
12	$1 == $1 && $2 == $2	# test some string compares
13	$1 != $2
14{
15	sss = ""
16	for (i = NF; i > 0; i--)
17		sss = sss " " $i
18	print sss
19}
20{
21	xx[$1] += length
22}
23END {
24	for (i in xx)
25		print i, xx[i] | "sort"
26}
27NF % 2 == 0
28length % 2 == 0
29! /^./
30/.$/
31BEGIN { xxx = ".$" }
32$0 ~ xxx
33{ print substr($0, 10,10) }
34{ $3 = "xxx" $3 "xxx"; $4--; print }
35{ for (i = 1; i <= NF; i++)
36	x[i] = $i
37  for (i = 1; i <= NF; i++)
38	print x[i]
39}
40{ for (i = 1; i <= NF; i++)
41	y[i] = $i
42  for (i = 1; i <= NF; i++)
43	printf "%d %s\n", i, y[i]
44}
45function abs(x) { return (x < 0) ? -x : x }
46BEGIN {	n = 1000
47	for (i = 1; i < n; i++) x[i] = rand()
48	for (i in x)
49		for (j in x)
50			if (abs(x[i]-x[j]) < .01) break
51      }
52