[Top][All Lists]

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

Re: [bug-gawk] $'$' syntax

From: Aharon Robbins
Subject: Re: [bug-gawk] $'$' syntax
Date: Fri, 27 Jan 2012 11:42:50 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hello. Re this:

> From: "Susan Hoddinott" <address@hidden>
> To: <address@hidden>
> Date: Thu, 26 Jan 2012 16:41:52 +0800
> Subject: [bug-gawk] $'$' syntax
> Hello,
> I am trying to build output strings from dynamic variables, e.g. name
> = "$j, $(j+1)", etc.  I receive syntax errors if I do not use double
> quotes at this point and when I try to print the value of the variable,
> if I use name I get $j, etc. output without transalation, if I use $name
> I get the whole file and if I use $'$'name I get another syntax error.
> Is there a special syntax I need to use for the Windows version to get
> the variable to be evaluated when printed, or is this a bug ?
> Regards,
> Susan Hoddinott
> http://www.hexworx.com

It's not a bug.  However, it is a case that the language does not do what you
want it to do.  There is no 'eval' capability as in shell or Perl.

Also note that $<something> is how you access fields in gawk, not variable
values.  Thus $foo retrieves the value of the variable foo, converts it to
a number, and retrieves that input field.

You may wish to invest some time in reading the gawk documentation to come
more up to speed on the awk language. (Or move to Perl.)



reply via email to

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