小编ste*_*ers的帖子

从shell中的通配符搜索中排除字符串

我试图从文件搜索中排除某个字符串.

假设我有一个文件列表:file_Michael.txt,file_Thomas.txt,file_Anne.txt.

我希望能够写出类似的东西

ls *<and not Thomas>.txt
Run Code Online (Sandbox Code Playgroud)

给我file_Michael.txt和file_Anne.txt,但不是file_Thomas.txt.

反过来很容易:

ls *Thomas.txt
Run Code Online (Sandbox Code Playgroud)

使用单个字符执行此操作也很容易:

ls *[^s].txt
Run Code Online (Sandbox Code Playgroud)

但是怎么用字符串呢?

塞巴斯蒂安

bash wildcard

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

bash ×1

wildcard ×1