免费注册 查看新帖 |

Chinaunix

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

bash中 @(a|b)是什么意思? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-27 16:08 |只看该作者 |倒序浏览
看到在bash_completion中:
if [[ ${COMP_WORDS} == @(install|remove|autoremove|purge|source|build-dep) ]];
请教这句中的 @(install|remove|autoremove|purge|source|build-dep) 作何解释?

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亚洲杯之朝鲜
日期:2015-03-13 22:47:33IT运维版块每日发帖之星
日期:2016-01-09 06:20:00IT运维版块每周发帖之星
日期:2016-03-07 16:27:44
2 [报告]
发表于 2009-08-27 16:17 |只看该作者

回复 #1 netcafe 的帖子

pattern match

论坛徽章:
0
3 [报告]
发表于 2009-08-27 16:49 |只看该作者

回复 #1 netcafe 的帖子

bash里面有这个脚本吗?  能贴出来看看不?

论坛徽章:
0
4 [报告]
发表于 2009-08-28 13:25 |只看该作者
Pattern Matching

       Any  character  that  appears in a pattern, other than the special pattern characters described below, matches itself.  The NUL character may not occur in a pattern.  A back‐
       slash escapes the following character; the escaping backslash is discarded when matching.  The special pattern characters must be quoted if they are to be matched literally.

       The special pattern characters have the following meanings:

       *      Matches any string, including the null string.  When the globstar shell option is enabled, and * is used in a filename expansion context, two adjacent  *s  used  as  a
              single  pattern  will match all files and zero or more directories and subdirectories.  If followed by a /, two adjacent *s will match only directories and subdirecto‐
              ries.
       ?      Matches any single character.
       [...]  Matches any one of the enclosed characters.  A pair of characters separated by a hyphen denotes a range expression; any character that sorts between those two  charac‐
              ters, inclusive, using the current locale's collating sequence and character set, is matched.  If the first character following the [ is a !  or a ^ then any character
              not enclosed is matched.  The sorting order of characters in range expressions is determined by the current locale and the value of the LC_COLLATE shell  variable,  if
              set.  A - may be matched by including it as the first or last character in the set.  A ] may be matched by including it as the first character in the set.

              Within [ and ], character classes can be specified using the syntax [:class:], where class is one of the following classes defined in the POSIX standard:
              alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
              A character class matches any character belonging to that class.  The word character class matches letters, digits, and the character _.

              Within  [  and  ], an equivalence class can be specified using the syntax [=c=], which matches all characters with the same collation weight (as defined by the current
              locale) as the character c.

              Within [ and ], the syntax [.symbol.] matches the collating symbol symbol.

       If the extglob shell option is enabled using the shopt builtin, several extended pattern matching operators are recognized.  In the following description, a pattern-list is a
       list of one or more patterns separated by a |.  Composite patterns may be formed using one or more of the following sub-patterns:

              ?(pattern-list)
                     Matches zero or one occurrence of the given patterns
              *(pattern-list)
                     Matches zero or more occurrences of the given patterns
              +(pattern-list)
                     Matches one or more occurrences of the given patterns
              @(pattern-list)
                     Matches one of the given patterns
              !(pattern-list)
                     Matches anything except one of the given patterns
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP