File: duplicates.awk

package info (click to toggle)
arpwatch 2.1a15-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,984 kB
  • sloc: sh: 3,047; ansic: 2,811; makefile: 90; awk: 90; perl: 15
file content (28 lines) | stat: -rw-r--r-- 333 bytes parent folder | download | duplicates (7)
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
# combine company info for duplciate vendor codes

BEGIN {
	str = ""
	lastv = ""
}

{
	v = $1
	if (v == lastv) {
		i = index($0, "	")
		# XXX probably can't happen
		if (i <= 0)
			i = 0
		str = str " *also* " substr($0, i + 1)
	} else {
		if (str != "")
			print str
		str = $0
	}
	lastv = v

}

END {
	if (str != "")
		print str
}