Last active
March 15, 2022 17:15
-
-
Save michaelskyba/84d054b583d5a98780f4fea7ac67c216 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Edit this if you're not using TSV | |
DELIM=" " | |
doc=' | |
descript: convert scripture decks to tunnel decks | |
usage: descript <deck file> | |
This prints to stdout so you can do something like | |
descript deck > deck2 | |
diff deck deck2 | |
and ensure that it worked | |
This script assumes TSV splitting - edit the $DELIM variable at the top | |
if you are using something else | |
' | |
[ -z "$1" ] \ | |
&& echo "$doc" \ | |
&& exit 1 | |
[ -f "$1" ] || invalid=1 | |
[ "$invalid" ] \ | |
&& echo "Invalid input: $1" \ | |
&& exit 1 | |
while read -r line | |
do | |
splits=$(echo "$line" | sed "s/[^$DELIM]//g" | awk '{ print length }') | |
comment=0 | |
[ "$splits" = 5 ] || comment=1 | |
[ "$comment" = 1 ] \ | |
&& echo "$line" \ | |
&& continue | |
I=$(echo "$line" | cut -d"$DELIM" -f 5) | |
I=${I%%.*} | |
date=$(echo "$line" | cut -d"$DELIM" -f 6) | |
date=$(date -d "$date" +%s) | |
else=$(echo "$line" | cut -d"$DELIM" -f "1-4") | |
echo "$else$DELIM$I$DELIM$date" | |
done < "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/michaelskyba/scripture
https://github.com/michaelskyba/tunnel