上QQ阅读APP看书,第一时间看更新
The echo command
The echo builtin command just repeats the arguments you provide it onto the standard output:
$ echo Hello Hello
This makes it a simple way to emit content to the terminal, including variables:
$ echo 'Hello, '"$USER"\! Hello, bashuser!
The echo command in Bash has switches that allow you to control the output, such as excluding the final newline, or expanding sequences such as \t to tab characters. However, we caution against using echo in scripts, because for historical reasons it has broken design and portability problems that makes it confusing or error-prone to use, especially when trying to use it with switches. We suggest you always use printf in scripts instead, as its behavior is more predictable, especially when printing variables or control characters such as newlines.