-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompute-apk-sizes.sh
More file actions
executable file
·50 lines (43 loc) · 1015 Bytes
/
Copy pathcompute-apk-sizes.sh
File metadata and controls
executable file
·50 lines (43 loc) · 1015 Bytes
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
50
#!/bin/bash
# Compute total size of each file type from APK listing
# Usage: unzip -l schmeep.apk | ./compute-apk-sizes.sh
awk '
BEGIN {
in_data = 0
}
# Detect start of file listing (line with dashes)
/^---------/ {
in_data = 1
next
}
# Process file lines (length in field 1, filename in field 4)
in_data && /^[[:space:]]*[0-9]/ {
size = $1
filename = $4
# Extract extension
if (match(filename, /\.([^.\/]+)$/)) {
ext = substr(filename, RSTART+1)
} else if (filename ~ /\/$/) {
ext = "directory"
} else {
ext = "no-extension"
}
# Accumulate totals
total[ext] += size
count[ext]++
}
END {
# Sort by total size (descending)
for (ext in total) {
printf "%12d %6d %s\n", total[ext], count[ext], ext
}
}
' | sort -rn | awk '
BEGIN {
printf "%-12s %6s %s\n", "Total Bytes", "Count", "Extension"
printf "%-12s %6s %s\n", "------------", "------", "---------"
}
{
printf "%-12s %6s %s\n", $1, $2, $3
}
'