Date: Sat, 10 Oct 2009 07:41:19 -0700 (PDT) From: Richard Mahlerwein <mahlerrd@yahoo.com> To: FreeBSD-Questions <freebsd-questions@freebsd.org> Subject: Re: conky calendar Message-ID: <319011.88077.qm@web51006.mail.re2.yahoo.com>
next in thread | raw e-mail | index | archive | help
>From: Roland Smith <rsmith@xs4all.nl>=0A>Subject: Re: conky calendar=0A>To= : "PJ" <af.gourmet@videotron.ca>=0A>Cc: freebsd-questions@freebsd.org=0A>Da= te: Saturday, October 10, 2009, 9:27 AM=0A>=0A>On Sat, Oct 10, 2009 at 05:0= 1:34AM -0400, PJ wrote:=0A>> I'm having a bit of a time with the calendar.s= h script I =0A>> found on the Net; it doesn't display quite correctly.=0A>>= It should have brackets around the current date, but I =0A>> can't figure = out what is not functioning correctly:=0A>> =0A>> #!/bin/sh=0A>> cal | awk = 'NR>2' | sed -e 's/=A0=A0=A0/=A0 =A0 /g' -e 's/[^ ] /& /g' -e 's/..*/=A0 & = /' -e 's/ \('`date | awk '{print $2}'`'\) /\['`date | awk '{print $2}'`'\]/= '=0A>=0A>Look at the output of the date command:=0A>Sat Oct 10 15:12:39 CES= T 2009=0A>=0A>Change 'print $2' to 'print $3' to get the numercal date.=0A>= Or even simpler: use "date +%d" instead of "date | awk '{print $3}'".=0A>= =0A>Roland=0A=0AI could not get it to work until I changed the single quote= s in the last -e expression to double quotes. (This either interactively u= nder csh or as a script under sh). BTW, using `date +%s` and with an addit= ional minor change to make the numbers continue to line up ... Oh! This wi= ll not fix mis-alignments on days when it is not the end of the week, I don= 't think ... anyway.=0A=0Acal | awk 'NR>1' | sed -e 's/ / /g' -e 's/[^= ] /& /g' -e 's/..*/ &/' -e "s/\ `date +%d`/\[`date +%d`\]/"=0A=0AGives=0A= $ sh newcal.sh=0A Su Mo Tu We Th Fr Sa=0A 1 2 = 3=0A 4 5 6 7 8 9 [10]=0A 11 12 13 14 15 16 17=0A 18 19= 20 21 22 23 24=0A 25 26 27 28 29 30 31=0A=0ANow, if you had a = space character at the end of each line, you could do something like ...=0A= =0Acal | awk 'NR>1' | sed -e 's/ / /g' -e 's/[^ ] /& /g' -e 's/..*/ &= /' -e "s/\ `date +%d`\ /\[`date +%d`\]/"=0A=0AAnd then it would replace (un= derscore is space) "_8_" with "[8]" so it would always line up. You can't = do that without the space at the end of the line because the trailing numbe= rs look like this "_17" not "_17_". But, fix that, and you can use the abo= ve. That is left as an exercise for the reader. =0A=0A-Rich=0A=0A=0A =
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?319011.88077.qm>