I have a problem with echo in my script:
echo -n "Some string..."
prints
-n Some string...
and moves to the next line. In the console it’s working correcly without newline:
Some string...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are multiple versions of the
echocommand, with different behaviors. It’s often built into the shell. If it isn’t,echowill typically invoke/bin/echoor/usr/bin/echo, which itself can be from any of a number of implementations.Apparently the shell used for your script uses a version that doesn’t recognize
-n.The
printfcommand has much more consistent behavior.echois fine for simple things likeecho hello, but I suggest usingprintffor anything more complicated.What system are you on, and what shell does your script use?