-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-toc.sh
executable file
·68 lines (43 loc) · 1.28 KB
/
create-toc.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#For xtrace / debugging
#set -x
# if [ "$#" -ne 1 ]; then
# usage
# exit
# fi
outfile='readme.md'
# Add preamble for the readme
cat << INTRO > ${outfile}
# Readme
This repository contains quite useful resources on the following topics.
Its in constant update, feel free to **Star** or **Watch** this repository, so that you get update notification as and when we update.
You may fork this repo and you can add your own awesome tools, techs that you find useful, and you can submit pull request
INTRO
# adding the content of banner to make readme nice
cat banner.txt >> $outfile
cat contributing-guide.md >> $outfile
while read -r line
do
# Extract the first line of each file.
fileheading=$(head -n 1 $line)
# Remove the leading pound symbol
fileheading="${fileheading:1}"
echo "* [$fileheading]($line)" >> ${outfile}
done < <(ls *.md)
OUT=$?
if [ $OUT -eq 0 ];then
echo "TOC generated [Success]"
else
echo "TOC generation encountered error !!! "
fi
# Add credit
cat << EOFFF >> ${outfile}
#### Note
This file was auto generated by **Table of content generator** [create-toc.sh](create-toc.sh)
EOFFF
OUT=$?
if [ $OUT -eq 0 ];then
echo "Readme file created [Success]"
else
echo "Readme file creation encountered problem."
fi