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

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

printf expert system idea; gawk printf peculiarity


From: Dan Jacobson
Subject: printf expert system idea; gawk printf peculiarity
Date: 28 Oct 2001 04:51:59 +0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Given that gawk is rightly picky here:

BEGIN{printf "%s%s%s", a,a}
awk: a.awk:1: fatal: not enough arguments to satisfy format string
        `%s%s%s'
            ^ ran out for this one

then how could it just let smile and let this past:

BEGIN{printf "%s%s%s", a,a,a,a}

Oh and by the way, why does it say "ran out for this one" when it
really ran out for the last one.

GNU Awk 3.1.0

And while we're here, how do I printf
input     output
----------------
20      20
20.1    20.1
20.111  20.1
20.0    20
1.1     1.1
1       1

i.e. input=20.111; printf %???, input #will give me 20.1, and so forth...

I looked at the printf(3) page real long but couldn't figure out the
right % sequence.

HEY, I just thought up a new idea for a GNU tool, a printf control
sequence expert system!   Feed it a table of what kind of outputs one
would like for various inputs, and the expert system will tell you
what possible printf control sequences can satisfy your demands!

The more examples you give it, the narrower the choices become.
e.g. if you only give it
input     output
----------------
0       0
then %d %g ... are all valid answers...

Hmmm, maybe
input     output
----------------
float   21.212
would be a better way to specify input... but: it wouldn't be as
sensitive as my first example...
-- 
http://www.geocities.com/jidanni Tel+886-4-25854780



reply via email to

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