From owner-freebsd-questions@FreeBSD.ORG Sun Aug 31 00:12:16 2008 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 D1FD11065672 for ; Sun, 31 Aug 2008 00:12:16 +0000 (UTC) (envelope-from rambiusparkisanius@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.232]) by mx1.freebsd.org (Postfix) with ESMTP id 8BE498FC0A for ; Sun, 31 Aug 2008 00:12:16 +0000 (UTC) (envelope-from rambiusparkisanius@gmail.com) Received: by wr-out-0506.google.com with SMTP id c8so871383wra.27 for ; Sat, 30 Aug 2008 17:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=7qr7uWDte48QqPEPYuOWYtvqnnFWN+H2XV9aeAIdjXQ=; b=rGrxiQ3zJOgIteREuXZWaA4XUaEyoZUvoDD5y9puyii/K/bAvHDZgjQYY5XMmQuPOa 8rK8svq8ea0tb+8aTMyC8Nfkix0lIiRYc9OLVFb9SWNqgnLszp1YuOmzvEYmaTNDDBeX xsX0ijpLkpFkwCM1dq7tWziw46fSSLYC8BHvY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=NdrQOa4zHN/wD5HvZjuCJKpGdtiNeq5tqmA/WgrqiPz6V8sf4RoSdi9J++6JcMfG1a eEL939uD+pkodIZay201ko6QZVm8teEpiyKcQ8qAGuojl4V1Zcv5G84DjGN401e0XvG+ vXQacbHUUYqzm1o1N9FhcaL7J43Nu99SR1ykE= Received: by 10.90.72.3 with SMTP id u3mr5601388aga.45.1220140327790; Sat, 30 Aug 2008 16:52:07 -0700 (PDT) Received: by 10.90.89.18 with HTTP; Sat, 30 Aug 2008 16:52:07 -0700 (PDT) Message-ID: <89ce7f740808301652g169fa4d2v3fe5eff06100e31e@mail.gmail.com> Date: Sun, 31 Aug 2008 02:52:07 +0300 From: "Ivan \"Rambius\" Ivanov" To: "FreeBSD Questions" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Formatting dates to a specific pattern X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Aug 2008 00:12:16 -0000 Hello, I need to format the current date (as returned by date(1) ) to the pattern m-d-yyyy, where m is the month in one or digits, d is the day in one or two digits, and yyyy is the year in four digits. The problem for me is the day and the month, for example August should be 8, and not 08, and 5th of September should be 9-5-2008 and not 09-05-2008. I read the man page of date(1) but date(1) seems to always put leading zeros. I appreciate any help on how to format the date the way I want. In case you wonder why I need such a format: I am using a hosting company to run a web site. They are backing up my files in a .tar.gz archive and I can download it. The name of the backup archive contains the date formatted as I explained. I want to write a daily cron job script that will download the backup for me. Regards Rambius -- Tangra Mega Rock: http://www.radiotangra.com