- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2017-04-12 15:23 编辑
回复 3# yufeiluo
你这个问题...
应该自己去理解...
在不同情境中,有不同结果
在shell command line,
会经过两个转换...
1. shell
2. utility (echo)
$ echo "\n"
\n
#note: shell: \n => \n , echo without -e , output \n directly
$ echo "\\n"
\n
#note: shell: \\ => \ , echo without -e , output \ + n directly
$ echo -e "\n"
#note: shell: \n => \n , echo with -e , transfer \n to newline
$ echo -e "\\n"
#note: shell: \\ => \ , echo with -e , transfer \ + n to newline
$ set -x
$ echo "123\\\\\\nabc" <=== shell , \\ => \
+ echo '123\\\nabc' <=== echo without -e, didn't change anything
123\\\nabc
$ echo -e "123\\\\\\nabc" <=== shell , \\ => \
+ echo -e '123\\\nabc' <=== echo with -e, \\ => \ , \n => newline
123\
abc
|
|