文件匹配模式如何使用 Asterisk 准确工作?
How File matching patterns exactly works using Asterisk?
我有以下文件:
C:\files\file1.dll
C:\files\file2.dll
C:\files\sample\sample1.dll
c:\files\sample\sample2.dll
c:\files\book\book1.dll
c:\files\book\book2.dll
c:\files\book\comic\comic1.dll
c:\files\book\comic\comic2.dll
模式 1 是 *\*.dll
,模式 2 是 *\comic\*.dll
,模式 3 是 book\*\*.dll
。哪些文件应匹配 pattern1
、pattern2
和 pattern3
第一个模式应该匹配通配符匹配中的所有内容。你基本上是在说。
包含 \
并以 .dll
结尾
第二个应该与最后两个匹配。
包含 \comic\
并以 .dll
结尾
最后一个应该什么都不匹配。
以 book\
开头包含 \
并以 .dll
结束
这当然是针对此处描述的模式匹配 而不是正则表达式。
在 glob
世界中,情况并非如此:
** matches any character including a forward-slash /
* matches any character except a forward-slash (to match just the file or directory name)
所以这样想。第一个模式只会匹配第一个和第二个。通过使用双 ** 你有效地说,我也关心子目录。
带有更多示例的出色解释:
我有以下文件:
C:\files\file1.dll
C:\files\file2.dll
C:\files\sample\sample1.dll
c:\files\sample\sample2.dll
c:\files\book\book1.dll
c:\files\book\book2.dll
c:\files\book\comic\comic1.dll
c:\files\book\comic\comic2.dll
模式 1 是 *\*.dll
,模式 2 是 *\comic\*.dll
,模式 3 是 book\*\*.dll
。哪些文件应匹配 pattern1
、pattern2
和 pattern3
第一个模式应该匹配通配符匹配中的所有内容。你基本上是在说。
包含 \
并以 .dll
第二个应该与最后两个匹配。
包含 \comic\
并以 .dll
最后一个应该什么都不匹配。
以 book\
开头包含 \
并以 .dll
结束
这当然是针对此处描述的模式匹配
在 glob
世界中,情况并非如此:
** matches any character including a forward-slash /
* matches any character except a forward-slash (to match just the file or directory name)
所以这样想。第一个模式只会匹配第一个和第二个。通过使用双 ** 你有效地说,我也关心子目录。
带有更多示例的出色解释: