Add plaintext.sh Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Fri, 24 Jan 2020 18:33:59 +0530
2 files changed,
17 insertions(+),
1 deletions(-)
A
bin/plaintext.sh
@@ -0,0 +1,16 @@
+#!/bin/sh + +# from the pure sh bible; see: +# https://github.com/dylanaraps/pure-sh-bible#get-the-base-name-of-a-file-path +basename() { + dir=${1%${1##*[!/]}} + dir=${dir##*/} + dir=${dir%"$2"} + base="${dir:-/}" +} + +for p in pages/blog/*.md; do + basename "$p" + [ "$base" != "_index.md" ] && + cp "$p" "build/blog/${base%.*}.txt" +done