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:
cat list
Just use printf
instead, since it does not print the new line as default:
printf "final line" >> file
Let's create a file and then add an extra line without a trailing new line. Note I use cat -vet
to see the new lines.
$ seq 2 > file
$ cat -vet file
1$
2$
$ printf "the end" >> file
$ cat -vet file
1$
2$
the end