From: Aleksander Fetininsky <sashurik@aviel.ru>
To: Community <community@altlinux.ru>
Subject: Re: [Comm] Задачка
Date: Fri, 15 Jul 2005 22:46:04 +0400
Message-ID: <20050715184604.GB2674@sashurik.aviel.ru> (raw)
In-Reply-To: <20050712114332.4150060e.pvs@vdnet.ru>
On Tue, Jul 12, 2005 at 11:43:32 +0400, Pavel Shurubura wrote:
> Здравствуйте !
>
> Есть текстовый файл с разделителями '|' (pipe).
> В поле номер 5 есть дата такого формата:
> Thu, 07 Jul 2005 14:12:01 +0400
> т.е.
>
> 123|Text|234|aaa|Thu, 07 Jul 2005 14:12:01 +0400|dsfas|asdkfj
>
> Как-бы мне её преобразовать в число секунд since epoch ?
>
> командочка date +'%s' 'Thu, 07 Jul 2005 14:12:01 +0400'
> Выдаёт мне то,что надо. Как вставить её вывод обратно в файл ?
>
> на awk пытался передать параметр функции system таким образом:
> {
> system("date +%s $5");
> }
> Но так не получается. Может подскажет кто чего ?
>
> Спасибо.
С приведёнными данными вот такая строка команды работает:
echo "123|Text|234|aaa|Thu, 07 Jul 2005 14:12:01 +0400|dsfas|asdkfj" | awk
-F\| '{ OFS="|"; $5=D; print$0 }' D=`date +'%s' --date='Thu, 07 Jul 2005
14:12:01+0400'`
123|Text|234|aaa|1120731121|dsfas|asdkfj
Теперь остаётся решить, как передавать awk нужные строки, нужную дату, и
как потом заменять их в файле на строки с изменённым 5-м полем.
Удачи.
Александр.
prev parent reply other threads:[~2005-07-15 18:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-12 7:43 Pavel Shurubura
2005-07-12 7:59 ` Pavel Shurubura
2005-07-12 8:01 ` Dmytro O. Redchuk
2005-07-12 8:23 ` Pavel Shurubura
2005-07-15 18:46 ` Aleksander Fetininsky [this message]
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=20050715184604.GB2674@sashurik.aviel.ru \
--to=sashurik@aviel.ru \
--cc=community@altlinux.ru \
/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