Skip to content

Instantly share code, notes, and snippets.

@rey
Created January 25, 2015 16:55
Show Gist options
  • Select an option

  • Save rey/f6d6a1dcb30b1be18f00 to your computer and use it in GitHub Desktop.

Select an option

Save rey/f6d6a1dcb30b1be18f00 to your computer and use it in GitHub Desktop.
Quick way to log stuff
#!/bin/bash
#
# Usage: sh log.sh
#
# fire up vim and create `temporary` file
vim temporary
# if there are contents in `temporary`
if [ -s temporary ]; then
# write the current date to a new file called `saving`
echo $(date +"%a %d %B %y @ %H:%M") > saving
# stick `temporary` to the bottom of `saving`
cat temporary >> saving
# stick a blank line to the bottom of `saving`
echo >> saving
# write `saving` to the top of `log.markdown`
echo "$(cat saving log.markdown)" > log.markdown
echo "The following was logged:"
echo
cat saving
# delete `saving`
rm saving
# scp
# scp log.markdown user@server:/home/user/log/log.markdown.${HOSTNAME}
else
echo "temporary has no contents and will not be saved"
fi
# delete `temporary`
rm temporary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment