Created
January 25, 2015 16:55
-
-
Save rey/f6d6a1dcb30b1be18f00 to your computer and use it in GitHub Desktop.
Quick way to log stuff
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/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