echo默认是有换行的, -n的时候, 是不换行的, 看下man的介绍:
ubuntu@VM-0-13-ubuntu:~$ man echo | grep "\-n" -C2
Echo the STRING(s) to standard output.
-n do not output the trailing newline
-e enable interpretation of backslash escapes
ubuntu@VM-0-13-ubuntu:~$
看下实际例子:
ubuntu@VM-0-13-ubuntu:~$ echo "abc" > a.txt
ubuntu@VM-0-13-ubuntu:~$ xxd a.txt
0000000: 6162 630a abc.
ubuntu@VM-0-13-ubuntu:~$
ubuntu@VM-0-13-ubuntu:~$
ubuntu@VM-0-13-ubuntu:~$
ubuntu@VM-0-13-ubuntu:~$ echo -n "abc" > a.txt
ubuntu@VM-0-13-ubuntu:~$ xxd a.txt
0000000: 6162 63 abc
ubuntu@VM-0-13-ubuntu:~$
其中, 0a就是换行。
不多说。