Rahul wrote:
> Is there something akin to a "heredoc" in awk? I need to process a set
of
> records, extract relevant numbers from each record and then create a
> formatted multi-line output for each record. Problem is that the output
> would contain a lot of special characters and using a normal print or
> printf would need me to do some nasty quoting (or not?)
The only characters I can think of that need "special quoting" are the
double quotes and the backslash escape character. Though you can use
variables to get the quotes quite legible. See the example...
BEGIN { Q = "\"" }
{
print Q "id" Q ":" Q "town"
print Q $1 Q ":" Q $2
}
Janis
>
> The desired output snippet for each record is something like this:
>
> {"id":"town",
> "label":"middleton",
> "x_size":"10.22",
> "y_size":"5.22",
> },
>
>
> Of course, I'd be using $1 (or equivalent variables) for the town,
> middleton, 10.22, 5.22 etc.
>
> Any constructs like the familiar bash
>
> print << EOF
> static blah blah
> "${var_to_be_inserted}"
> more static blah blah
> EOF
>


|