-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcounter.sh
executable file
·33 lines (27 loc) · 948 Bytes
/
counter.sh
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
#!/usr/bin/env bash
# Set the README file
readme_file="README.md"
# Check if the file exists
if [[ ! -f "$readme_file" ]]; then
echo "Error: $readme_file not found!"
exit 1
fi
# Function to count entries matching a pattern
count_entries() {
local pattern=$1
grep -E "$pattern" "$readme_file" | wc -l
}
# Patterns for entries
total_pattern='^- \*\*\[[^]]+\]\(.*\)\*\*'
magisk_pattern='^- \*\*\[[^]]+\]\(.*\)\*\*.*\[M\]'
lsposed_pattern='^- \*\*\[[^]]+\]\(.*\)\*\*.*\[LSP\]'
# Count entries
total_entries=$(count_entries "$total_pattern")
magisk_modules=$(count_entries "$magisk_pattern")
lsposed_modules=$(count_entries "$lsposed_pattern")
root_apps=$((total_entries - magisk_modules - lsposed_modules))
# Output in Markdown-friendly format
echo "- ##### Total Entries: \`$total_entries\`"
echo "- ##### Root Apps: \`$root_apps\`"
echo "- ##### Magisk Modules: \`$magisk_modules\`"
echo "- ##### LSPosed Modules: \`$lsposed_modules\`"