bash - 如何列出具有特定扩展名的每个文件,除了带有 bash 的文件
问题描述
所以我有一个目录,其中包含多个不同类型的文件(例如 pdf、txt 等)。假设我想选择 .example 类型的每个文件,除了一个我将如何去做?假设这些文件都称为 ex_.example,其中 _ 是 0 到 30 之间的数字。
我试过 ls ex*[^12]*.example; 我得到了除了 1、2、11、12、21 和 22 之外的每个示例文件。我不明白除了 JUST 文件号 12 之外,我怎么能得到每个文件。
谢谢!
解决方案
您可以使用扩展通配符。引用Bash 参考手册:
!(pattern-list)
匹配除给定模式之一之外的任何内容。
shopt -s extglob # enables extended globbing
ls -l ex!(12).example # for more numbers, you can use !(12|18|...)
推荐阅读
- javascript - 在 JSPDF 中为所有屏幕添加页眉和页脚
- java - 如何防止使用静态分析工具在代码中使用指定的类/方法?
- c# - 从运行 C# Windows 应用程序的 Docker 容器访问主机文件夹路径
- javascript - 空() div + 变量
- angular - Angular Material 单元测试 - 找不到 MatHarness 元素
- embedded - 如何决定何时在浮点数上使用定点算法?
- javascript - HTTP POST 请求适用于 Postman,但不适用于我的 Web 应用程序的 JavaScript 提取
- angular - 使用 ng-packagr 制作 Angular mono-repo 库
- python - 无法在 KIVY Python 中打印取自 kivy.uix.textinput.TextInput 的文本
- javascript - 选择具有相同属性 data-img_key="bull3" 的所有行