问题描述
我只是想知道什么是文件泛滥?我以前从没听说过,尝试在线查找时找不到定义.
I was just wondering what is file globbing? I have never heard of it before and I couldn't find a definition when I tried looking for it online.
推荐答案
globbing是*
和?
以及您可能熟悉的其他一些模式匹配器.
Globbing is the *
and ?
and some other pattern matchers you may be familiar with.
当外壳程序看到一个glob时,它将执行 pathname扩展,并在调用程序时用匹配的文件名替换该glob.
When the shell sees a glob, it will perform pathname expansion and replace the glob with matching filenames when it invokes the program.
以*
运算符为例,假设您要将当前目录中所有扩展名为.jpg
的文件复制到其他位置:
For an example of the *
operator, say you want to copy all files with a .jpg
extension in the current directory to somewhere else:
cp *.jpg /some/other/location
此处*.jpg
是全局模式,与当前目录中所有以.jpg
结尾的文件匹配.这等效于(并且比列出目录要容易得多)并列出您要手动输入的每个文件:
Here *.jpg
is a glob pattern that matches all files ending in .jpg
in the current directory. It's equivalent to (and much easier than) listing the current directory and typing in each file you want manually:
$ ls
cat.jpg dog.jpg drawing.png recipes.txt zebra.jpg
$ cp cat.jpg dog.jpg zebra.jpg /some/other/location
请注意,它可能看起来相似,但与正则表达式不相同.
Note that it may look similar, but it is not the same as Regular Expressions.
这篇关于什么是文件泛滥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!