forked from FrannyZhao/gitbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_summary.sh
executable file
·48 lines (46 loc) · 1.42 KB
/
gen_summary.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
summaryFile=summary.txt
rm -rf $summaryFile
tree Algorithms Android Basic_Knowledge CodeManagement Others | while read line
do
#echo $line
if [ "${line: 0-3}" == "pic" -o "${line: 0-3}" == "png" -o "${line: 0-3}" == "jpg" -o "${line: 0-3}" == "bmp" -o "${line: 0-3}" == "JPG" -o "${line: 0-4}" == "webp" ]; then
continue
fi
if [ "$line" == "" ]; then
break
fi
if [ "${line: 0:1}" == "│" -o "${line: 0:1}" == "└" -o "${line: 0:1}" == "├" ]; then
if [ "${line: 0-2}" == "md" ]; then
echo $line" is sub file"
filename=`echo "$line" | awk -F " " '{printf($NF)}'`
name1=`echo $filename | sed -e "s/.md//g"`
name2=`echo $name1 | sed -e "s/\./ /g"`
fileSummary=""
i=0
for name in `echo $name2`; do
if [ $i == 0 ]; then
fileSummary=$fileSummary"${name^}"
else
fileSummary=$fileSummary" ${name^}"
fi
let 'i+=1'
done
fileSummary=$fileSummary"]("$path"/"$filename")"
echo " * ["$fileSummary >> $summaryFile
else
echo $line" is sub dir"
dirname=`echo "$line" | awk -F " " '{printf($NF)}'`
path=$head"/"$dirname
echo " * "$dirname >> $summaryFile
fi
else
echo $line" is head"
head=$line
path=$line
echo "* "$line >> $summaryFile
fi
done
echo ""
echo "summary:"
cat $summaryFile