Skip to content

Instantly share code, notes, and snippets.

@shadowlightwolf89
Last active August 29, 2015 14:24
Show Gist options
  • Save shadowlightwolf89/e06554a3851d666ea2ca to your computer and use it in GitHub Desktop.
Save shadowlightwolf89/e06554a3851d666ea2ca to your computer and use it in GitHub Desktop.
Bash Templating with File Names
layout title date category
post
test
2015-07-03 13:50:48 -0700
update
$ bash ./create.sh update test
#!/bin/sh
NOW=$(date +"%Y-%m-%d")
NOWT=$(date +"%Y-%m-%d %H:%M:%S")
sed -e "s;%DATE%;$NOWT;g" -e "s;%CAT%;$1;g" -e "s;%SLUG%;$2;g" template.txt > $NOW-$2.md
---
layout: post
title: %SLUG%
date: %DATE%
category: %CAT%
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment