列出具有数字名称的文件

Vic*_*cky 2 unix linux bash shell

如何列出仅具有数字名称的文件,例如

1111 
2342 
763
71
Run Code Online (Sandbox Code Playgroud)

我已经尝试过 ls -l [0-9]* ,但这似乎会带来所有以数字开头的文件名,并且数字后的名称中可以包含任何内容。

rob*_*off 7

首先,打开 Bash 的extglob选项:

shopt -s extglob
Run Code Online (Sandbox Code Playgroud)

然后使用这个模式:

ls -l +([0-9])
Run Code Online (Sandbox Code Playgroud)

在Bash 参考手册中阅读有关扩展模式匹配的更多信息。