Skip to content

Instantly share code, notes, and snippets.

@jiyeonseo
Created January 12, 2019 15:21
Show Gist options
  • Save jiyeonseo/2b30b152767caeb5f334fe4882cecfd3 to your computer and use it in GitHub Desktop.
Save jiyeonseo/2b30b152767caeb5f334fe4882cecfd3 to your computer and use it in GitHub Desktop.
migration_post.sh
#!/bin/bash
for entry in "$PWD"/blog/*
do
writeAt=$(basename $entry | awk -F'[-.]' '{print $1"-"$2"-"$3}') # extract data from file name
dateFormat='date: '$writeAt'' # date string aligned with markdown format
printf '%s\n' H 4i "$dateFormat" . wq | ed -s $entry # insert date string.
done
@jiyeonseo
Copy link
Author

This script is for migration blogs post which don't have "date" info in the file.
extracting date from file name and insert into file as date: '2019-01-13'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment