Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Append text with echo without new line

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?
by

1 Answer

Bharatgxwzm
I don't think it's possible with echo command, use the following sed approach instead:
sed -i '$ s/$/abc/' file.txt


-i - modify the file inplace
$ - indicate the last record/line
s/$/abc/ - substitute the end of the line $ with substring abc (for the last record)

Login / Signup to Answer the Question.