匹配Bash中所有文件/目录名(包括以点开头的文件)的最短表达式是什么?

问题描述 投票:0回答:1

我设置了extglob,未设置dotglob。>>

[.*也会产生...,与mvcp结合使用非常邪恶。

[我玩了一会儿,发现*(?(.)+([^.]))$(ls -A)给出了理想的结果,但我认为应该有一种更简单的方法...

编辑:对不起,我应该提到我正在寻找要在提示符下而不是脚本内使用的表达式。

我设置了extglob,未设置dotglob。 。*也会产生。和..与mv或cp结合使用时非常邪恶。我玩了一下,发现*(?(。)+([^。]))和$(ls -A)给出了所需的结果,但是我...

bash glob dotfiles
1个回答
2
投票
unset GLOBIGNORE  # empty-by-default, but let's make sure
shopt -s dotglob  # disable special handling for "hidden" files

# ...and with the above items both done:
files=( * )       # just an example use of a glob
© www.soinside.com 2019 - 2024. All rights reserved.