layout | title | date | category |
---|---|---|---|
post |
test |
2015-07-03 13:50:48 -0700 |
update |
Last active
August 29, 2015 14:24
-
-
Save shadowlightwolf89/e06554a3851d666ea2ca to your computer and use it in GitHub Desktop.
Bash Templating with File Names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bash ./create.sh update test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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