Unix通配符选择器?(星号) [英] Unix wildcard selectors? (Asterisks)

查看:31
本文介绍了Unix通配符选择器?(星号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Ryan Bates 的 Railscast 关于 git 中,他的 .gitignore 文件包含以下行:

In Ryan Bates' Railscast about git, his .gitignore file contains the following line:

tmp/**/*

使用双星号后跟一个星号的目的是什么:**/*?仅使用 tmp/* 而不是 tmp/**/* 会不会达到完全相同的结果?

What is the purpose of using the double asterisks followed by an asterisk as such: **/*? Would using simply tmp/* instead of tmp/**/* not achieve the exact same result?

谷歌搜索这个问题,我发现了一篇关于它的不清楚的 IBM 文章,我想知道是否有人可以澄清这个问题.

Googling the issue, I found an unclear IBM article about it, and I was wondering if someone could clarify the issue.

推荐答案

它说进入 tmp 下的所有子目录,以及只进入 tmp 的内容.

It says to go into all the subdirectories below tmp, as well as just the content of tmp.

例如我有以下几点:

$ find tmp
tmp
tmp/a
tmp/a/b
tmp/a/b/file1
tmp/b
tmp/b/c
tmp/b/c/file2

匹配输出:

$ echo tmp/*
tmp/a tmp/b

匹配输出:

$ echo tmp/**/*
tmp/a tmp/a/b tmp/a/b/file1 tmp/b tmp/b/c tmp/b/c/file2

这是 zsh 的默认功能,要使其在 bash 4 中工作,您需要执行:

It is a default feature of zsh, to get it to work in bash 4, you perform:

shopt -s globstar

这篇关于Unix通配符选择器?(星号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆