日時を指定してログを取得(rcs)

今回は日時を指定してログを表示します。

使い方はドキュメントを確認。

info rcsのDate optionより

2.1.2 Date option
-----------------

Some commands accept an option of the form ‘-dDATE’ to specify a "date",
an absolute point in time (to second resolution), expressed in a "date
format".  These also accept ‘-zZONE’ to specify the timezone.  The
special value ‘LT’ stands for the "local time zone".  RCS recognizes
many date formats and time zones.  For example, the following dates are
equivalent if local time is January 11, 1990, 8pm Pacific Standard Time,
eight hours west of Coordinated Universal Time (UTC):

     8:00 pm lt
     4:00 AM, Jan. 12, 1990           default is UTC
     1990-01-12 04:00:00+00           ISO 8601 (UTC)
     1990-01-11 20:00:00-08           ISO 8601 (local time)
     1990/01/12 04:00:00              traditional RCS format
     Thu Jan 11 20:00:00 1990 LT      output of ctime(3) + LT
     Thu Jan 11 20:00:00 PST 1990     output of date(1)
     Fri Jan 12 04:00:00 GMT 1990
     Thu, 11 Jan 1990 20:00:00 -0800  Internet RFC 822
     12-January-1990, 04:00 WET

Most fields in the date and time can be defaulted.  The default time
zone is normally UTC, but this can be overridden by the ‘-z’ option.
The other defaults are determined in the order year, month, day, hour,
minute, and second (most to least significant).  At least one of these
fields must be provided.  For omitted fields that are of higher
significance than the highest provided field, the time zone’s current
values are assumed.  For all other omitted fields, the lowest possible
values are assumed.  For example, without ‘-z’, the date ‘20, 10:30’
defaults to ‘10:30:00 UTC’ of the 20th of the UTC time zone’s current
month and year.  Note that for the shell, the date/time must be quoted
if it contains spaces.

現状のログからdateの行を抽出。

takk@deb9:~/tmp$ rcs log test2.c | grep ^date
date: 2018/09/29 11:26:09;  author: takk;  state: Exp;  lines: +1 -1
date: 2018/09/28 12:36:32;  author: takk;  state: Exp;  lines: +1 -1
date: 2018/09/23 07:04:11;  author: takk;  state: Exp;  lines: +1 -1
date: 2018/09/23 06:56:47;  author: takk;  state: Exp;
date: 2018/09/30 10:36:53;  author: takk;  state: Exp;  lines: +1 -1
takk@deb9:~/tmp$

では、-dオプションを使ってみましょう。2018-09-30のログを取得します。

takk@deb9:~/tmp$ rcs log -d2018-09-30 test2.c

RCS file: RCS/test2.c,v
Working file: test2.c
head: 2.2
branch: 1
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;     selected revisions: 1
description:
test
----------------------------
revision 2.2
date: 2018/09/29 11:26:09;  author: takk;  state: Exp;  lines: +1 -1
test
=============================================================================
takk@deb9:~/tmp$

2018-09-29が表示されてしまいました。
時刻が同じか超えていないといけないですね。

takk@deb9:~/tmp$ rcs log -d"2018-09-30 10:36:53" test2.c

RCS file: RCS/test2.c,v
Working file: test2.c
head: 2.2
branch: 1
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;     selected revisions: 1
description:
test
----------------------------
revision 1.10.1.1
date: 2018/09/30 10:36:53;  author: takk;  state: Exp;  lines: +1 -1
branch test
=============================================================================
takk@deb9:~/tmp$

2018-09-30のログになりました。

未来の日付にすると、どうなるでしょうか。

takk@deb9:~/tmp$ rcs log -d2020-01-01 test2.c

RCS file: RCS/test2.c,v
Working file: test2.c
head: 2.2
branch: 1
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;     selected revisions: 1
description:
test
----------------------------
revision 1.10.1.1
date: 2018/09/30 10:36:53;  author: takk;  state: Exp;  lines: +1 -1
branch test
=============================================================================
takk@deb9:~/tmp$

最新のログを表示するようです。

次は時刻だけ指定。

takk@deb9:~/tmp$ rcs log -d"01:10:50" test2.c

RCS file: RCS/test2.c,v
Working file: test2.c
head: 2.2
branch: 1
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;     selected revisions: 1
description:
test
----------------------------
revision 1.10.1.1
date: 2018/09/30 10:36:53;  author: takk;  state: Exp;  lines: +1 -1
branch test
=============================================================================
takk@deb9:~/tmp$

最新のログが表示されました。時刻だけ指定すると、今日が指定されるんですね。

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA