Skip to content
Advertisement

Bash: add string to the end of the file without line break

How can I add string to the end of the file without line break?

for example if i’m using >> it will add to the end of the file with line break:

JavaScript

I would like to add yourText2 right after yourText1

JavaScript

Advertisement

Answer

JavaScript

If your sed implementation supports the -i option, you could use:

JavaScript

With the second solution you’ll have a backup too (with first you’ll need to do it manually).

Alternatively:

JavaScript

or

JavaScript
Advertisement