Google Groups Home Help | Sign in
Message from discussion How awk `split' works?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
PRC  
View profile
 More options May 8, 6:49 am
Newsgroups: comp.unix.shell
From: PRC <panruoc...@gmail.com>
Date: Thu, 8 May 2008 03:49:28 -0700 (PDT)
Local: Thurs, May 8 2008 6:49 am
Subject: How awk `split' works?
The results of running the following script
gawk 'BEGIN {
    n = split("(a,b,c,d)", a, /[(,)]/);
    printf("n=%d\n", n);
    for(i=1; i<=n; i++)
        printf(" -%s-\n",a[i]);
}'

is
n=6
 --
 -a-
 -b-
 -c-
 -d-
 --

instead of
n=4
 -a-
 -b-
 -c-
 -d-
which is expected.

I have no ideas how these results come out.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google