-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathskeleton.sh
executable file
·50 lines (38 loc) · 1.19 KB
/
skeleton.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
echo "running the script file skeleton.sh"
reg="[0-9]{2}"
rpl="---------------------------------------------------------------------"
for x in *.Rmd
do
if ! [[ $x =~ $reg ]]
then
continue
fi
x_out="intro-to-r-course-notes/${x}"
x_out=${x_out/.Rmd/.R}
echo "creating ${x_out} from ${x}"
# delete lines which do not start with hash or caret
# delete lines in the challenges between details tags
# add line of dashes below section header lines
# remove trailing dashes under challenge header lines
# surround script title with mulitple hashes`
# lines in challenges still start with right angle bracket. replace with hash
# remove trailing information on challenge times
# remove start and end chunk lines
# remove blank lines starting with a hash
sed -E \
-e '/^(>|#)/ !d' \
-e '/<details>/,/<\/details>/d' \
-e 's/^(##)(.*)$/\1\2\n## '"$rpl"' \n\n\n\n/' \
$x > tmpfile.txt
sed -E \
-e '1s/^(#)(.*)$/######### \2 #########/' \
-e '/^#([[:alnum:]])/d' \
-e 's/^>/#/' \
-e 's/(### Challenge [0-9])(.*)/#\1/' \
-e '/^(# `)/d' \
-e '/^#([[:space:]])$/d' \
-e 's/(#### Challenge [0-9]\n)//' \
tmpfile.txt > $x_out
done
#rm tmpfile.txt