Skip to content

Instantly share code, notes, and snippets.

@ghostbar
Last active March 2, 2017 21:10
Show Gist options
  • Save ghostbar/ed98f2c8fb604d9747bcc3b0391019c2 to your computer and use it in GitHub Desktop.
Save ghostbar/ed98f2c8fb604d9747bcc3b0391019c2 to your computer and use it in GitHub Desktop.
modify_file() {
sed -i "s/title/date\: $2T00:00:00-04:00\ntitle/" "$1"
}
for item in *.md; do
exists="$(grep "^date: " "$item")"
if [ -z "$exists" ]; then
echo "$item"
what_date="$(echo "$item" | cut -c 1-10)"
modify_file "$item" "$what_date"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment