Blog your status to a file using Bash

I wanted to take notes about what I’m currently doing at work, but I didn’t want to upload this info to Twitter or Facebook.
I also wasn’t in the mood to put MySQL and Tomcat to work hard on my laptop.
I just wanted something off-line and local for security.

I wrote this bash script to log my comments to a file.

# Just display entries when you don't pass parameters
if [ $# -gt 0 ]
    DATE=$(date +"%m/%d/%Y %r")
    #use $@ to print out all arguments at once
    echo [$DATE] $@ >> $HOME/work.log
# display last 4 entries
tail -n 4 $HOME/work.log

Save this as $HOME/bin/log

Use it like this:

~$ log Today I worked on XX project

and it will display:

[01/11/2010 03:41:59 PM] Way older post
[01/11/2010 03:43:01 PM] Older post
[01/12/2010 08:24:34 AM] Old post
[01/12/2010 02:31:47 PM] Today I worked on XX Project

Call it without arguments to simply display the last 4 entries without logging anything new.

This entry was posted in Bash and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted March 23, 2010 at 5:20 pm | Permalink

    Simple, but looking good.
    I waste more time writing on file… im my current job all taks must be
    described to full fill a task list report, i will improve your script in future
    to write comma separated style for export to xls/ods format :] and then full the status report.


  2. Posted February 9, 2011 at 5:23 am | Permalink

    Great script! Might use this to keep track of my daily activity instead of writing in a notepad ++ file.

Post a Comment

Your email is never published nor shared. Required fields are marked *