Friday, May 3, 2024
14
rated 0 times [  14] [ 0]  / answers: 1 / hits: 18726  / 2 Years ago, sat, june 11, 2022, 7:59:09

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.


More From » command-line

 Answers
0

Better to use:



printf "Different characters can be represented and supported

in the print command, for example:

x-y, X+Y, –, +, <, >, %%, $, #, &.
"


You get that error, as others have said here, because of % character which is special and must to be escaped.



See man 1 printf for more info.


[#28379] Monday, June 13, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tigehanc

Total Points: 162
Total Questions: 113
Total Answers: 122

Location: Zambia
Member since Sat, Oct 31, 2020
4 Years ago
tigehanc questions
;