bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Read one character at a time


From: Manuel Collado
Subject: Re: [bug-gawk] Read one character at a time
Date: Wed, 23 Jan 2019 11:28:59 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

El 22/01/2019 a las 22:57, Andrew J. Schorr escribió:
...
There may be a better solution, but here's one that puts each character
into the RT variable:

bash-4.2$ echo 'abc
def' | gawk -v 'RS=.{1}' '{printf "[%s]\n", RT}'
[a]
[b]
[c]
[
]
[d]
[e]
[f]
[
]

I feel RS="(.)" a simpler idiom than RS=".{1}". But, of course, this is a matter of taste. And RS=".?" also works in this case.

But why RS="" doesn't deliver each input character as a record? It gives the whole file as a single record. This seems to be inconsistent w.r.t. FS="". The latter lets each character to become a field.

I've not found an explicit mention to RS="" in the docs. Maybe I'm missing something, but the section about record splitting doesn't contains a summery subsection similar to the summary for FS values.

Regards.

--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado




reply via email to

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