File: del1

package info (click to toggle)
apt-move 4.2.26-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 256 kB
  • ctags: 79
  • sloc: sh: 1,569; awk: 257; cpp: 116; perl: 85; makefile: 27
file content (49 lines) | stat: -rwxr-xr-x 738 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/awk -f

BEGIN {
	err = "/dev/stderr"
}

{
	idx = $0
	filefield = 0
	split("", files)

	while ((val = getline < idx) > 0) {
		if (filefield) {
			if (substr($0, 1, 1) == " ") {
				files[$3] = 1
				continue
			} else {
				filefield = 0
			}
		}
		x = index($0, ":")
		if (!x) {
			continue
		}
		key = tolower(substr($0, 1, x - 1))
		if (key == "directory") {
			dir = substr($0, x + 1)
			sub(/  */, "", dir)
		} else if (key == "filename") {
			file = substr($0, x + 1)
			sub(/  */, "", file)
			print file "\t" idx
			close(idx)
			next
		} else if (key == "files") {
			filefield = 1
		}
	}

	if (val < 0) {
		print "Failed to read " idx > err
		exit 1
	}
	close(idx)

	for (i in files) {
		print dir "/" i "\t" idx
	}
}