Skip to content

Commit 0b0e497

Browse files
authored
Create script to automatically update all article 'Update dates' (RoboticsKnowledgebase#80)
1 parent 8b6af09 commit 0b0e497

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

date.bash

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# On this date all posts were updated with the date field
4+
# We want to ignore this date
5+
all_change_date=2020-05-12
6+
7+
# Go through all files in the wiki folder
8+
for file in `find wiki/ -name '*.md'`; do
9+
# Get last date on which file was updated
10+
last_change=$(git log -1 --format="%ad" --date=short $file)
11+
if [ "$last_change" = "$all_change_date" ]; then
12+
# If the last change was on the all_change_date
13+
# set last_change to last change before all_change_date
14+
last_change=$(git log -1 --format="%ad" --before=$all_change_date --date=short $file)
15+
fi
16+
# Replace date filed with last_change
17+
sed -i "s/date:.*/date: $last_change/" $file;
18+
done

0 commit comments

Comments
 (0)