> `cat /dev/urandom` since well after you started_ 

c u t u p @ c u t u p . o r g


[bash calendar oneliner] last modified: 05/04/2008 10:27 am

I made a nifty little one liner so cal will show you the current date. It even makes sure not sure not to mess up the formatting. I'm sure this is like, the millionth time this was invented, and I'm sure there's a better way to do it, and it's not even technically a one-liner, though it is short.

DATE=`date +%d`;REP=`echo $DATE | sed 's/./#/g'`;cal | sed "s/ $DATE / $REP /"

and you get something like:

    December 2005
 S  M Tu  W Th  F  S
             1  2  3
 4  5  6  7  8  9 10
11 12 ## 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31


UPDATE: already found a better one:

cal | sed "s/ $(date +%d) / $(date +%d | sed 's/./#/g') /"

UPDATE 2: it worked till the 17th, oops! Not all the dates have spaces on both sides. The best thing i could think of to do was just add spaces on each end of the lines, so now I'm using:

cal | sed "s/^/ /;s/$/ /;s/ $(date +%d) / $(date +%d | sed 's/./#/g') /"

UPDATE 3: thanks to someone at MacGeekery, I learned how to use shell escape codes. So here's a version that just bolds the current date:

cal | sed "s/^/ /;s/$/ /;s/ $(date +%d) /$(printf '\e[1m&\e[m')/"

UPDATE FOR NEW YEAR: you need to strip the leading zero from the date:

cal | sed "s/^/ /;s/$/ /;s/ $(date +%d | sed 's/^0//') /$(printf '\e[1m&\e[m')/"


cal | sed "s/^/ /;s/$/ /;s/ $(date +%e) /$(printf '\e[1m&\e[m')/"


cal | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/./#/g') /"


cal | sed "s/.*/ & /;s/ $(date +%e) / [] /"

[All Posts] [top]