Skip to content

Commit 0aac48a

Browse files
committed
clean_toc.sh for multiple directories
1 parent 2323bef commit 0aac48a

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Diff for: bin/clean_toc.sh

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/bin/bash
22

3-
POST_DIR=$(dirname "$(dirname "$(realpath "$0")")")/_posts
4-
echo $POST_DIR
5-
6-
# 检测一个文件夹下所有的md格式的文件
7-
for file in $POST_DIR/*.md; do
8-
# 检查文件第一行是否包含 [toc]
9-
if [[ $(head -n 1 "$file") == "[toc]" ]]; then
10-
# 删除第一行以及后面的空行
11-
sed -i -e '1,/^$/d' "$file"
12-
fi
3+
DIRECTORIES=("_posts" "_tutorials")
4+
5+
for dir in "${DIRECTORIES[@]}"; do
6+
DIR=$(dirname "$(dirname "$(realpath "$0")")")/$dir
7+
echo $DIR
8+
9+
for file in $DIR/*.md; do
10+
if [[ $(head -n 1 "$file") == "[toc]" ]]; then
11+
sed -i -e '1,/^$/d' "$file"
12+
fi
13+
done
1314
done
15+

0 commit comments

Comments
 (0)