Shell Scripting Help
Brian Fahrlander
brian at fahrlander.net
Tue May 15 09:39:22 UTC 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Nils Kassube wrote:
> Ghodmode wrote:
>> # Let the shell do the basic math instead of calling an external
>> program
>
> I like your logic, although I'd say "Better let date do the math instead
> of writing a faulty script" :)
>
>> if [ $DAY -eq 0 ]; then
>> MONTH=$(( MONTH - 1 ))
>> [ $MONTH -eq 0 ] && $MONTH = 12
>
> E.g. the last line should be
>
> [ $MONTH -eq 0 ] && MONTH=12 && YEAR=$(($YEAR - 1))
>
> but this is untested, so it might be faulty as well.
>
>> On 5/15/07, Nils Kassube <kassube at gmx.net> wrote:
>>> How about this one?
>> echo "1 day ago was: $(date -d yesterday '+%m %d %Y')"
>>
>>
>> Thanks, Nils.. I didn't know date had that argument :)
>
> That's the beauty of the date command -- it understands many verbose
> descriptions of the date / time to display. Meanwhile i think it would
> have been more consistent to write the command like this:
>
> echo "1 day ago was: $(date -d '1 day ago' '+%m %d %Y')"
Well, isn't that the coolest thing? Thanks so much; the changes
that get made to such longstanding code, when your back's turned. Thanks
so much for pointing it out!
:)
(The other email was a massive typo; sorry)
- --
------------------------------------------------------------------------
Brian Fahrländer Christian, Conservative, and Technomad
Evansville, IN http://Fahrlander.net/brian
ICQ: 5119262 AOL/Yahoo/GoogleTalk: WheelDweller
------------------------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGSX/K6PLtRzZbdhYRAmYVAJ9otESkTspWqkLCRI6t2cs7itM9OQCeKxW8
47VzDGN1uJJLKsaOeEkGfrU=
=fJjy
-----END PGP SIGNATURE-----
More information about the ubuntu-users
mailing list