1、为什么\n在soft quoting中没转义?而\\在soft quoting中转义了?
这是特殊约定?还是?
2、另外对escape和转义表达式相同的情况(如\n)一直这样理解:在hard/soft quoting外都是escape,在之内的话,需要根据具体的命令来判断是否具有转义功能,如echo默认没有转义,加了-e则表示转义,而grep等默认就有转义。不知道这样理解正确否?
hbmhalley 发表于 2012-05-14 22:11
本来 "" 里就不进行 ansi-c 转义,echo -e 里是 echo 命令自己转义的,和 shell 无关
\ 还是有用的,比如 ...
3.1.2.3 Double Quotes
Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. The characters ‘$’ and ‘`’ retain their special meaning within double quotes (see Shell Expansions). The backslash retains its special meaning only when followed by one of the following characters: ‘$’, ‘`’, ‘"’, ‘\’, or newline. Within double quotes, backslashes that are followed by one of these characters are removed. Backslashes preceding characters without a special meaning are left unmodified. A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an ‘!’ appearing in double quotes is escaped using a backslash. The backslash preceding the ‘!’ is not removed.
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |