I want to append text to file like echo "abc" >>file.txt
.
But this add abc
after new line
How can I add abc
in the end of file with echo without new line?
echoio-redirectionshelltext processing
I want to append text to file like echo "abc" >>file.txt
.
But this add abc
after new line
How can I add abc
in the end of file with echo without new line?
Best Answer
Assuming that the file does not already end in a newline and you simply want to append some more text without adding one, you can use the
-n
argument, e.g.However, some UNIX systems do not provide this option; if that is the case you can use
printf
, e.g.(the initial
%s
argument being to guard against the additional text having%
formatting characters in it)From
man echo
(on macOS High Sierra):