help-bash
[Top][All Lists]
Advanced

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

Re: printf $variable inside initial parenthesis or use %s?


From: Roger
Subject: Re: printf $variable inside initial parenthesis or use %s?
Date: Thu, 12 Jan 2023 21:06:51 -0500

Hello Mr Wooledge!

Now why didn't I think of that?

Roger

On Thu, Jan 12, 2023 at 5:16 PM Greg Wooledge <greg@wooledge.org> wrote:

> On Thu, Jan 12, 2023 at 05:06:02PM -0500, Roger wrote:
> > Another idea, initially write scripts using echo, then later re-code/fix
> and
> > use printf.
> >
> > This will save a lot of typing time, with echo/printf statements being
> added
> > and removed during development (although I usually leave most
> echo/printf
> > statements for later debugging), that do not remain in the final end
> product or
> > working script.  Like I previously stated, printf %s syntax format tends
> to
> > double typing time.  Albeit, using this tactic, most will just forget
> and keep
> > the echo statements!
>
> If you wish to continue using echo for convenience/brevity, you can
> drop a function like this into your script:
>
> echo() { local IFS=' '; printf '%s\n' "$*"; }
>
> That will make echo behave the way most people want/expect it to:
> print each argument verbatim, with spaces between them if there's
> more than one, and then print a newline at the end.
>
>


reply via email to

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