post-shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

if [ $# == 0 ]
then
echo 'Add failed'
exit
fi

_date=`date '+%Y-%m-%d'`
_time=`date '+%Y-%m-%d %H:%M:%S'`
_file="./_posts/${_date}-$1.md"
echo $_time

printf "%s%s%s\r\n" '-' '-' '-' > $_file

printf "title: $1\r\n" >> $_file
printf "date: ${_time}\r\n" >> $_file
printf "categories:\r\n" >> $_file

printf "%s%s%s\r\n" '-' '-' '-' >> $_file

echo $_file
echo 'Added successfully'