[Top][All Lists]

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

Re: echo -n

From: Stephane Chazelas
Subject: Re: echo -n
Date: Thu, 2 Feb 2017 17:18:47 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

2017-02-02 22:26:22 +0530, Jyoti B Tenginakai:
> I have tried using the printf instead of echo. But the issue with printf
> is , the behaviour is not consistent with what echo prints for all the
> inputs i.e.
> In my script I am generically using echo for all the options. If I have to
> use printf instead of it should behave consistently .
> if echo * is passed to bash shell, the o/p shows the \t seperated values
> whereas with printf '%s'  *, it won't display space separated output. Again
> printf '%s ' # behaviour is different from what echo # shows

See also:


In bash, you can define:

puts() {
  local IFS=' '
  printf '%s\n' "$*"

as a function that outputs its arguments separated by spaces and
terminated with a newline character.


puts() (
  IFS=' '
  printf '%s\n' "$*"

With with some shells like bash, that implies an additional

Note hat ksh and zsh also have:

print -r -- *

for that.


reply via email to

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