help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Escape Character and NewLine


From: David
Subject: Re: [Help-bash] Escape Character and NewLine
Date: Tue, 17 Sep 2019 07:15:23 +1000

On Tue, 17 Sep 2019 at 06:12, Fernando Basso <address@hidden> wrote:
> On Mon, Sep 16, 2019 at 4:40 PM Greg Wooledge <address@hidden> wrote:
> > On Mon, Sep 16, 2019 at 04:16:51PM -0300, Fernando Basso wrote:

> > Since printf has a format specifier with only one placeholder in it, but
> > it receives two arguments after the format spec, it implicitly loops,
> > and applies the format spec to each of the following arguments in turn.
> >
> > printf '%s\n' foo
> > printf '%s\n' bar
> >
> > OK. That is more or less what I had in mind (that is why I mostly asked
> why example 2 didn't work).
>
> "it implicitly loops" is eye-opening, though!

Once you are aware of this, it can be a useful feature.
Wherever a printf command is provided, this is the usual behaviour.

The bash builtin printf is documented here:
$ help printf | grep 're-used'
    The format is re-used as necessary to consume all of the arguments.  If

For more extensive documentation, try the command
  man 3 printf
or read a book on the C language.



reply via email to

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