免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4765 | 回复: 6
打印 上一主题 下一主题

转义符'\' 在“”中是作为普通字符还是特殊字符? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-09-06 10:14 |只看该作者 |倒序浏览
#echo "\m"
#\m
这说明'\'是作为普通字符处理的
#echo "\""
#"
这说明'\'在“”中作为转义符使用将第二个"变为普通字符
那么'\'在""中到底是作为什么字符处理呢?

论坛徽章:
0
2 [报告]
发表于 2004-09-06 11:44 |只看该作者

转义符'\' 在“”中是作为普通字符还是特殊字符?

那要看他和哪个字符组合在一起啦

论坛徽章:
0
3 [报告]
发表于 2004-09-06 11:49 |只看该作者

转义符'\' 在“”中是作为普通字符还是特殊字符?

那在echo "\t"中它是作为普通字符吧?

论坛徽章:
0
4 [报告]
发表于 2004-09-06 12:06 |只看该作者

转义符'\' 在“”中是作为普通字符还是特殊字符?

原帖由 "wang_songyan"]那在echo "\t"中它是作为普通字符吧?[/quote 发表:

man一下echo,看看这个\t是干嘛的
[quote]      \t     horizontal tab

论坛徽章:
0
5 [报告]
发表于 2004-09-06 13:56 |只看该作者

转义符'\' 在“”中是作为普通字符还是特殊字符?


  1. 慢慢看吧,应该很权威了

  2. shell转义
  3. 1, Each of the metacharacters listed above (See Definitions above) has a
  4.         special meaning to the shell and causes termination of a word unless quoted.  
  5. 2, A character can be quoted (i.e., made to stand for itself) by       
  6.         preceding it with a \.  The pair \new-line is ignored.  
  7. 3, All characters enclosed between a pair of single quote marks (''), are quoted.  A
  8.         single quote cannot appear within single quotes.  
  9. 4, Inside double quote marks (""), parameter and command substitution occurs and \ quotes

  10. the
  11.         characters \, `, ", and $. (vita remark 句号) $* and $@ have identical meanings when

  12.         not quoted or when used as a parameter assignment value or as a file name. "$*"
  13.         is equivalent to "$1d$2d...", where d is the first character of the IFS parameter,
  14.          whereas "$@" is equivalent to "$1" "$2" ....             
  15. 5, The special meaning of keywords or aliases can be removed by quoting
  16.         any character of the keyword.  The recognition of function names or
  17.         special command names listed below cannot be altered by quoting them

复制代码

论坛徽章:
0
6 [报告]
发表于 2004-09-06 17:36 |只看该作者

转义符'\' 在“”中是作为普通字符还是特殊字符?

要看\后面的哪个字符是否可被转义,若后面的字符可被转义,则 \ 被当作转义字符,否则不是转义字符。如 n 可被转义为换行符,因此当 \ 后面有个n时,\被用作转义,shell认为 " 也是可被转义的,因此当 \ 后面有个 " 时,\ 也被用作转义了

论坛徽章:
0
7 [报告]
发表于 2004-09-06 20:21 |只看该作者

转义符'\' 在“”中是作为普通字符还是特殊字符?

明白了,感谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP