From owner-freebsd-questions@FreeBSD.ORG Sat Oct 10 14:41:20 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F6A51065670 for ; Sat, 10 Oct 2009 14:41:20 +0000 (UTC) (envelope-from mahlerrd@yahoo.com) Received: from web51006.mail.re2.yahoo.com (web51006.mail.re2.yahoo.com [206.190.38.137]) by mx1.freebsd.org (Postfix) with SMTP id CE40D8FC0C for ; Sat, 10 Oct 2009 14:41:19 +0000 (UTC) Received: (qmail 88422 invoked by uid 60001); 10 Oct 2009 14:41:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1255185679; bh=5LOOC3erDv6Y938YR5AUJWpv/PraHCDGCzHs/nbmBj0=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=NvQWvxlca5qAsBQRFFF8uKeKAlzNvzSxa00aaJLoFUZAtAeuTIQUJcYoG68vTFoc4rEuMWxeVxc3Okx0qrgPFuof5RdSez4V9dKg8R7zeLaVghM5n51gNPt026sPOPwXi42zz1pjoUUSTlqYJKJ0LRMyKoLkwzdbC/yLDPZwueM= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=pLx/x//Uu/mt8UO7HdwEyAz2QA7Tv6YkejGCv+nRbhqsgFTLl24jYcJw/09DfhPQh150DiDxANDNfpMTNsHcFYTzNf0cQ7qYkotAsOK+p3UJALR6r8qhw3nK8h4jhdzbBQx5J4UACV/H7mj2XDKR8biAHZ4egp/bO2u3E8A53W4=; Message-ID: <319011.88077.qm@web51006.mail.re2.yahoo.com> X-YMail-OSG: xe100sQVM1nBI8MFlIa8FBsyfxhmKRchwinf8GF7Q4GzabVZPsjIJ9O7oPcI6KvL.jOT51CQgzGook7clS5q1B96_ezPmlbvNxZ7Ncs8_lI7WQ4E1vAaAYnMF6u7CzfuDOUPPBwKyde97KJnHJQUT_iWqaIGFAFl6c.Ls0mcIY4pQKzTMghM07EQDBRxobwsctiqty2gZe7oVRwr4wP.jn7vLpoGbKeTu6ZqxWE143KSCfJtNVIRvzurBb2ma6lCGs0dVlaoNi67QRzS7doRSx_zvOvgnlAUMN_UxceOygudgXtaZx5tLMxgnRHo5hwjWyRQiSnxRJ.A_ddJrvyihnZgPp7amktPmRf1ZyxfAbvByXDB9xKsRpu10KpHIcINbwtMTTTUb9_KtG8m61SM9dEg3Ua7 Received: from [71.117.53.27] by web51006.mail.re2.yahoo.com via HTTP; Sat, 10 Oct 2009 07:41:19 PDT X-Mailer: YahooMailClassic/7.0.14 YahooMailWebService/0.7.347.3 Date: Sat, 10 Oct 2009 07:41:19 -0700 (PDT) From: Richard Mahlerwein To: FreeBSD-Questions MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: conky calendar X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: mahlerrd@yahoo.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Oct 2009 14:41:20 -0000 >From: Roland Smith =0A>Subject: Re: conky calendar=0A>To= : "PJ" =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 =