Suppose I have a file called
$ cat file Hello Welcome to Unix
I want to add
and Linux at the end of the last line of the file. If I do
echo " and Linux" >> file will be added to a new line. But I want last line as
Unix and Linux
So, in order to work around this, I want to remove newline character at the end of file. Therefore, how do I remove the newline character at the end of file in order to add text to that line?
sed '$s/$/ and linux/'