Skip to content

Instantly share code, notes, and snippets.

@tanakaworld
Created January 17, 2021 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanakaworld/519a3794d056cbc45d281ff1aa25c121 to your computer and use it in GitHub Desktop.
Save tanakaworld/519a3794d056cbc45d281ff1aa25c121 to your computer and use it in GitHub Desktop.
Convert posts of hexo to hugo.
# Dependencies
# - brew install gnu-sed
FILES='content/posts/*.md'
prefix='[[:digit:]][[:digit:]][[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]-'
suffix='.md'
for f in $FILES
do
# Insert slug from file name
r=$(basename $f)
r=$(echo $r | sed -e "s/^$prefix//" -e "s/$suffix$//")
echo "slug: $r"
gsed -i "3islug: $r" $f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment