From: "Aleksey E. Birukov" <birukov@vladinfo.ru>
To: "Шилов Сергей" <hsvhome@mail.ru>,
"ALT Linux sysadmin discuss" <sysadmins@lists.altlinux.org>
Subject: Re: [Sysadmins] awk
Date: Wed, 30 Jul 2008 20:58:05 +0400
Message-ID: <48909D9D.9050304@vladinfo.ru> (raw)
In-Reply-To: <E1KODCe-000Kgu-00.hsvhome-mail-ru@f17.mail.ru>
Шилов Сергей пишет:
> В сообщении от 30 июля 2008 Led написал:
>
>> В сообщении от Wednesday 30 July 2008 12:41:05 Sergey Shilov написал(а):
>>
>>> В сообщении от 30 июля 2008 Aleksey E. Birukov написал:
>>>
>>>>> Врядли. Я так понял, хотелось получить конкретный номерной match в
>>>>> случае когда FS - regexp
>>>>>
>>>> Да. Именно так.
>>>>
>>> echo "aaa_bbb_ccc" | NNN=2 awk -F"_[bc]" '{ printf "field%i=%s\n",
>>> (ENVIRON["NNN"]), $(ENVIRON["NNN"]) }
>>>
>> "Номерной match" FS, а не field
>>
>>
> Эээ..., тогда "в лоб":
> из "aaa_bbb_ccc_bad" в цикле берем в M 2-й match регэкспа "_[bc]" и печатаем полученное :-)
>
> echo "aaa_bbb_ccc_bad" | gawk -v N=2 -- '{ i = 0 ; S = $0 ; while ( match(S, /_[bc]/) != 0 ) { i++ ; M = substr(S, RSTART, RLENGTH) ; S = substr(S, RSTART+RLENGTH ) ; { if ( i == N ) { printf "%s\n", M ; break } } }'
>
Результат выполнения команды:
gawk: cmd.
line:1:
^ unexpected newline or end of string
С ходу не "просёк" что к чему...
next prev parent reply other threads:[~2008-07-30 16:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-29 11:25 Aleksey E. Birukov
2008-07-29 20:11 ` Sergey Shilov
2008-07-29 20:57 ` Led
2008-07-30 7:16 ` Aleksey E. Birukov
2008-07-30 9:41 ` Sergey Shilov
2008-07-30 10:27 ` Led
2008-07-30 15:03 ` Шилов Сергей
2008-07-30 16:58 ` Aleksey E. Birukov [this message]
2008-07-30 17:17 ` Alexey Borisenkov
2008-07-30 20:10 ` Sergey Shilov
2008-07-30 18:12 ` Led
2008-07-30 20:51 ` Sergey Shilov
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=48909D9D.9050304@vladinfo.ru \
--to=birukov@vladinfo.ru \
--cc=hsvhome@mail.ru \
--cc=sysadmins@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 sysadmins discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/sysadmins/0 sysadmins/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 sysadmins sysadmins/ http://lore.altlinux.org/sysadmins \
sysadmins@lists.altlinux.org sysadmins@lists.altlinux.ru sysadmins@lists.altlinux.com
public-inbox-index sysadmins
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.sysadmins
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git