问题描述
据我所知,通配符 *
(本身)会以这样的方式展开,这意味着隐藏的文件是在当前文件夹中所有非隐藏文件这些$ p $通过一段pfixed。
有,我会觉得是有用的两个用例,但我不知道如何正确地做:
-
你怎么可以使用通配的......在当前文件夹中的所有文件,包括隐藏文件,但不包括
。
或..
-
您如何能在当前文件夹中的glob的......所有隐藏文件(而且只有隐藏文件),但不包括
。
或..
要展开paviums回答并回答你问题的第二部分,所有的文件,除了。
和 ..
可指定像这样的:
{[!] *,*}
根据您的具体使用情况下,它可能会更好,设置 dotglob
外壳选项,这样的bash包括在扩展点文件 *
默认为:
$禁用了javascript -s dotglob
$回声*
.tst
I understand that the wildcard *
(by itself) will expand in such a way that it means "all non-hidden files in the current folder" with hidden files being those prefixed by a period.
There are two use cases that I would think are useful, but I don't know how to properly do:
How can you glob for... "All files in the current folder, including hidden files, but not including
.
or..
"?How can you glob for... "All hidden files (and only hidden files) in the current folder, but not including
.
or..
"?
To expand on paviums answer and answer the second part of your question, all files except .
and ..
could be specified like this:
{.[!.]*,*}
Depending on your exact use case it might be better to set the dotglob
shell option, so that bash includes dotfiles in expansions of *
by default:
$ shopt -s dotglob
$ echo *
.tst
这篇关于巴什通配符 - autoexpand几个具体的案例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!