连接两个文件而不添加换行符

ixt*_*lix 5 text-processing cat newlines

如果我有nano两个文件,其中一个文件读取“this”而不输入换行符,其中一个读取“is”而我不输入换行符,我希望能够cat将这两个文件一起转换为“thisis”。

相反,换行符是自动插入的。

alec@ROOROO:~/$ cat test1 test2 > test3
alec@ROOROO:~/$ cat test3
this
is
Run Code Online (Sandbox Code Playgroud)

那么,如何在不添加换行符的情况下连接两个文件?

man*_*ork 13

那些尾随的换行符是由nano而不是由cat

使用nano-L参数:

-L (--nonewlines)
    Don't add newlines to the ends of files.
Run Code Online (Sandbox Code Playgroud)

或者 ~/.nanorc 的nonewlines命令:

set/unset nonewlines
    Don't add newlines to the ends of files.
Run Code Online (Sandbox Code Playgroud)