I have to print the following three lines in one print command without using echo command. So I have chosen printf command.Here are the three lines:
Different characters can be represented and supported
in the print command, for example:
x-y, X+Y, –, +, <, >, %, $, #, &.
What I have done so far is:
printf "
Different characters can be represented and supported
in the print command, for example:
x-y, X+Y, –, +, <, >, %, $, #, &.
"
But I got bash error for the third line ','.
So will anyone enlighten me up.
Best Answer
%
is a special character inprintf
. That's what's causing the error. You need to escape it as%%
.$
may also be substituted when within double quotes by the outer shell, so you should to escape that (\$
). It is usually just easier to use single quotes.