Instantly share code, notes, and snippets.

@smirzai /dr.sh
Created Dec 15, 2017

Embed
What would you like to do?
A small script to create my daily report file
#!/bin/bash
# this script checks the $base_path folder
# if there is no dailr report for today, it will create it and replace the %current-date% to current date
# in any case, it returns the file name which makes it suitable for a command like:
# emacs `dr`
read Y M D MM <<< $(date +'%Y %m %d')
base_path=~/Documents/dailyReports
file_name="dailyreport-$Y-$M-$D.adoc"
full_path="$base_path/$file_name"
template_full_path="$base_path/dailyReport-template.adoc"
if [ ! -e "$full_path" ]; then
sed "s/%current-date%/$Y-$M-$D/g" < "$template_full_path" > "$full_path"
fi
echo $full_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment