Skip to content

Instantly share code, notes, and snippets.

@shaisachs
Created May 21, 2023 19:48
Show Gist options
  • Save shaisachs/4eac0ad808fdb795bec47bf03d38c462 to your computer and use it in GitHub Desktop.
Save shaisachs/4eac0ad808fdb795bec47bf03d38c462 to your computer and use it in GitHub Desktop.
# add date: field to every post in a directory, using the last git commit date for that post
for f in * ; do
echo $f
d=`git log -n 1 --date=format:'%Y-%m-%d %H:%M:%S' $f | grep Date | cut -c 9-`
sed -i -e '/^title:/a\
date: "$d"
' "$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment