[TUHS] non-Posix input files
arnold at skeeve.com
arnold at skeeve.com
Fri Mar 28 17:22:04 AEST 2025
Chet Ramey via TUHS <tuhs at tuhs.org> wrote:
> It also says "The standard utilities that have such restrictions always
> specify "text files" in their STDIN or INPUT FILES sections," so you can't
> avoid it.
>
> awk is one such utility (sh is not). This is an application requirement, so
> awk is required to add a newline at the end of a file that does not have
> one.
No awk I know of actually does that. Instead, they all treat end of file
as terminating the current input record:
$ for awk in gawk nawk mawk mksawk "busybox awk" goawk
> do echo == $awk
> echo -n ab:cd | $awk -v RS=: '{ print ">" $0 "<" }'
> done
== gawk
>ab<
>cd<
== nawk
>ab<
>cd<
== mawk
>ab<
>cd<
== mksawk
>ab<
>cd<
== busybox awk
>ab<
>cd<
== goawk
>ab<
>cd<
If a newline were being added, the output would have been:
>ab<
>cd
<
Nor is this something that I'm about to change, or suggest to any other
awk author to change.
My two cents,
Arnold
More information about the TUHS
mailing list