Wednesday, June 4, 2014

Reprint.

This is an article I wrote a long time ago, but found a minor error. Instead of going back and changing the original article, thought I would repost the article here.

---

Simple calendar

$ for i in {0..365};do date -d “Jan 1 2012 + $i day” + ”*%B %_d – “; done

In theory would print out:
*January 1 -
*January 2 -
*January 3 -
*January 4 -
*January 5 -

*December 28 -
*December 29 -
*December 30 -
*December 31 -

Now lets put that in a batch file called moncal.sh and mod it a little bit.

moncal.sh

[code]
# use start month and add number of days after the first day of that month i.e. ./moncal.sh Oct 60
let l=$2-1;for i in $(eval echo {0..$l});do date -d "$1 1 2012 + $i day" +"*%B %_d - ";done
[/code]

$ chmod +x moncal.sh

Then try it

$ ./moncal.sh Feb 29

You get:
*February 1 -
*February 2 -
*February 3 -
—–
*February 27 -
*February 28 -
*February 29 -

A little fun:

$ ./moncal.sh Feb 60

*February 1 -
*February 2 -
*February 3 -

*March 30 -
*March 31 -

Databook
$ ./moncal.sh Feb 29 > feb_databook

$ vim feb_databook

(or nano or gedit, or etc)

Insert data into file using underscores (easier to dump data into spreadsheet).

dateadd.sh:

[code]
read -p "Words to add to list: " t
t1=$(echo $t | sed -e 's/ /_/g')
sed '/'$2'/a
>_'$t1 $1 > test
mv test $1
[/code]

$ ./daterecord.sh Feb_datebook -3
Words to add to list: This date has passed
[eddie@oedt01 ~]$ cat Feb_datebook
*February -1 -
*February -2 -
*February -3 -
>_This_date_has_passed
*February -4 -
*February -5 -
*February -6 -

No comments:

Post a Comment