bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Is there a way to assign to a hash via the -v option


From: david kerns
Subject: Re: [bug-gawk] Is there a way to assign to a hash via the -v option
Date: Fri, 4 Mar 2016 15:22:33 -0700

how about this:

awk -v l="10,20" 'BEGIN{split(l,x,","); print x[1]; print x[2]}'

On Fri, Mar 4, 2016 at 1:56 PM, Peng Yu <address@hidden> wrote:
Hi, I want to assign to a hash via the -v option. But the following
does work. Is there anyway I can do it with -v?

$ awk -v "x[1]=10" -v "x[2]=20" 'BEGIN{print x[1]; print x[2]}'
awk: fatal: `x[1]' is not a legal variable name

--
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]