Mail script

Hi Folks

Please help me on the below script

I want to write a script to mail with the subject as "xxxxx" on (lastday-1)_month_year.

means for this month the subject is like "xxxx" on 30_jan_2013
for february the subject is like "xxxx" on 27_feb_2013

only the subject needs to change, please help me on this

Is this what you are trying to achieve?

$ sub=$( cal 2012 | awk '!/^$/{ld=$NF}END{printf "%d", ld-1;}' )
$ sub="${sub}_$( date +%b_%Y )"
$ echo $sub
30_Jan_2013

Dear folks,

In the below script i understand that ld means last day , but i didnt get these
" awk '!/^$/{ld=$NF " , can you please explain

Original script

$ sub=$( cal 2012 | awk '!/^$/{ld=$NF}END{printf "%d", ld-1;}' )
$ sub="${sub}_$( date +%b_%Y )"
$ echo $sub
30_Jan_2013

awk '!/^$/ is used to remove blank lines if any from cal command output.