如何在没有换行符的情况下将字符串添加到文件末尾?
例如,如果我使用>>它将添加到文件的末尾与换行符:
cat list.txt
yourText1
root@host-37:/# echo yourText2 >> list.txt
root@host-37:/# cat list.txt
yourText1
yourText2
Run Code Online (Sandbox Code Playgroud)
我想在yourText1之后添加yourText2
root@host-37:/# cat list.txt
yourText1yourText2
Run Code Online (Sandbox Code Playgroud) 我想合并两个文件cat file1 file2 > file3.但它从新线开始.我不希望这样.我可以使用tr将所有新行替换为空格,但我不能这样做,因为文件中有新行我不想替换.