Added bash script to edit weights easily
shoutout to @ecks0 for the bash wizardry
commit4e68eeb482ff5910fae13a9f7714c1709404f221
authorDavid Kerschner <dkerschner@hcoop.net>
dateWed 22 May 2019, 10:34 (7 years ago)
parent6b42d45
weights.shnew file+23
@@ -0,0 +1,23 @@
1+#!/bin/bash
2+
3+EDITOR=${EDITOR:-atom}
4+
5+# build weights file
6+for file in $(find -type f -name \*.md); do
7+ [[ $file == *_index.md ]] && continue
8+ echo $(grep -m 1 "weight = " $file | sed 's/^weight = //') $file
9+done | sort -n > weights
10+
11+# edit weights file
12+$EDITOR weights
13+read -p "Edit weights and press enter to continue..."
14+
15+# for each line in weights file, read values weight and file, and update
16+# $weight in $file
17+cat weights | while read weight file; do
18+ echo $weight $file
19+ sed -i'' "s/^weight = [.0-9]*/weight = $weight/" $file
20+done
21+
22+# remove weights file
23+rm weights