bug-bash
[Top][All Lists]
Advanced

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

Re: echo -n


From: Greg Wooledge
Subject: Re: echo -n
Date: Thu, 2 Feb 2017 10:08:01 -0500
User-agent: Mutt/1.4.2.3i

On Thu, Feb 02, 2017 at 02:32:00PM +0530, Sangamesh Mallayya wrote:
> in bash echo -n , echo -e , echo -E has a special meaning. But we do not 
> have a way in bash shell if we want to print 
> -n , -e and -E using echo command. Other shells supports printing of 
> -n/-e/-E options using echo command. 

Use printf instead of echo.

printf '%s\n' "$myvariable"

This will work regardless of the contents of the variable.

echo is deprecated, and should not be used unless you are certain that
it will not be given an argument that could be misinterpreted as an
option.

E.g. this is fine:

echo "You scored $points points."

This is not fine:

echo "$foo"

This was NEVER acceptable and you should not even THINK it:

echo $foo



reply via email to

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