-
Notifications
You must be signed in to change notification settings - Fork 0
/
c_md.sh
65 lines (44 loc) · 731 Bytes
/
c_md.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
#/bin/bash
# generate markdown template file
name=$1
suffix=${name##*.}
filename=$(echo $name | cut -d '.' -f1)
if [ $suffix -eq "md" ]; then
# do nothing
new_name=$filename".md"
else
new_name=$name".md"
fi
# get file name
md_name=$(basename $name)
# remove file suffix
new_md_name=${md_name%.*}
# check if name is empty
if [ ! $name ];
then echo "input file name."
exit -1
fi
# add template info
echo "
# "$new_md_name"
type:
difficulty:
---
## [Problem Info][problem_link]
## Attention
## Answer - 1
- java
- time: ms
- beat %
- big O:
## Answer - 2
- java
- time: ms
- beat %
- big O:
[problem_link]:
" > "$new_name"
if [ $? == 0 ]; then
echo "$new_md_name.md has been created."
fi
echo "done."