bug-gnu-utils
[Top][All Lists]
Advanced

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

Simple "print" in END condition prints last line


From: James Kanze
Subject: Simple "print" in END condition prints last line
Date: Thu, 28 May 2009 16:17:03 +0200

Not a serious problem, but a simple "print" in the END condition
prints the last line, e.g.:

    awk 'BEGIN { printf( "     " ) } ; /^#/ { next } ; { printf( "
%s", $2 ) } ; END { print }' rebuild.cmds

Where rebuild.cmds is:
    pagnu002 linux    comp=gcc           arch=i80x86  syst=linux
    padev001 suncc    comp=suncc         arch=sparc   syst=solaris
    padev001 sunccstl comp=suncc-stlport arch=sparc   syst=solaris
    padev001 gcc      comp=gcc           arch=sparc   syst=solaris
    padev001 v9       comp=suncc         arch=sparcv9 syst=solaris
    padev001 v9stl    comp=suncc-stlport arch=sparcv9 syst=solaris
    # pahmg001 linux64  comp=gcc           arch=x86_64  syst=linux
(no leading spaces) outputs:
      linux suncc sunccstl gcc v9 v9stl# pahmg001 linux64  comp=gcc
       arch=x86_64  syst=linux
instead of the desired:
      linux suncc sunccstl gcc v9 v9stl

The obvious work-around: replace the ``print'' with ``print
""''.  But print without an argument should output $0, and the
END condition doesn't have a $0.

-- 
James Kanze (GABI Software)             email:address@hidden
Conseils en informatique orientée objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34




reply via email to

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