ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: "Vladimir Karpinsky" <vkarpinsky@mail.ru>
To: "ALT Linux Community general discussions" <community@lists.altlinux.org>
Subject: Re: [Comm] Арифметика в bash
Date: Thu, 17 Nov 2011 13:31:15 +0400
Message-ID: <E1RQyJP-0003J5-00.vkarpinsky-mail-ru@f97.mail.ru> (raw)
In-Reply-To: <201111171217.36464.khedin@gmail.com>

17 ноября 2011, 12:19 от "Konstantin S. Uvarin" <khedin@gmail.com>:
>   Так пусть date и считает.
> 
>   JJJ=031
>   date -d "`date +%Y-1-1` + $JJJ days - 1 week"

Спасибо, я как-то об этом не подумал. По мотивам получилось так:

#!/bin/bash
jTODAY=`date +%j`
YEAR=`date +%Y`
DAY=`date -d 20110101 +%Y-%m-%d`
jDAY=`date -d 20110101 +%j`
until [ "$jDAY" -gt "$jTODAY" ]
do
        file="$YEAR"/"$jDAY".dat
        [ ! -f $file ] && echo "File $file is absent"
        DAY=`date -d "$DAY + 1 day" +%Y-%m-%d`
        jDAY=`date -d $DAY +%j`
done

Вероятно можно ещё красивше сделать...

--
  С уважением,
           Владимир.

  parent reply	other threads:[~2011-11-17  9:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-17  8:20   ` Константин Михайленко
2011-11-17  9:31     ` Vladimir Karpinsky [this message]
2011-11-17  9:35   ` Yura Kalinichenko
2011-11-17  9:50     ` Vladimir Karpinsky
2011-11-17  9:53       ` Vladimir Karpinsky
2011-11-17 15:50   ` Sergey Vlasov
2011-11-17 16:06     ` Vladimir Karpinsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1RQyJP-0003J5-00.vkarpinsky-mail-ru@f97.mail.ru \
    --to=vkarpinsky@mail.ru \
    --cc=community@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git