-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-readme.sh
29 lines (22 loc) · 971 Bytes
/
generate-readme.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
#!/bin/bash
[ ! -d ./output ] && { echo "Cannot generate README.md: lists folder not found."; exit 1; }
printf "# sinkhole\n\n" > ./output/README.md
printf "## Lists\n" >> ./output/README.md
for folder in ./output/*/; do
folder=${folder%*/}
listname=${folder##*/}
printf "\n### ${listname}\n\n" >> ./output/README.md
printf "|File|Entries|Size|Updated|Hash|\n" >> ./output/README.md
printf "|-|-|-|-|-|\n" >> ./output/README.md
for file in ${folder}/*; do
filename=$(echo ${file##*/} | cut -d. -f1)
fileurl=$(head -5 ${file} | sed -n 's/^.*File: //p')
entries=$(head -5 ${file} | sed -n 's/^.*Entries: //p')
filesize=$(stat -c '%s' ${file} | numfmt --to iec)
filedate=$(head -5 ${file} | sed -n 's/^.*Updated: //p')
filehash=$(sha256sum ${file} | head -c 64)
printf "|[${filename}](${fileurl})|${entries}|${filesize}|${filedate}|${filehash}|\n" >> ./output/README.md
done
done
echo "Finished generating README.md."
exit 0