When i try to append to the end of a file it creates a new line. Now I have tried to fix this with echo -n but that doenst work.
So what am I trying. I'm trying to get the following result:
Hello
This
Is
A
TestBut when I Append text with echo with
echo -n "Test2" >> file.txtThe following thing happens:
Hello
This
Is
A
Test
Test2But what I want is:
Hello
This
Is
A
Test Test2How am I able to do this? I have tried sed,echo and printf but none of these give the right result
01 Answer
With sed:
sed '$s/$/ Test2/' fileor
truncate -s-1 file
echo -n " Test2" >> fileOutput:
Hello This Is A Test Test28