正则表达式:不等于某个版本
Regexp: not equal certain version
如何为 return 所有文件夹指定正则表达式,但其名称中包含特定版本
比如我有这样的结构:
/tmp
|->java-1.9
|->libs-2.2.0-prebuild
| |-some content
|->libs-2.2.1-prebuild
| |-some content
|->libs-2.1.2-prebuild
| |-some content
我需要获取所有 libs 文件夹名称 Unix 的查找命令,但名称中包含特定版本的文件夹除外 (f.g.2.2.0)
我正在尝试这个命令,但它不起作用
find /tmp/ -maxdepth 1 -type d -regex '.*libs-((?!2\.2\.0).)*'
find
解法:
find /tmp/ -maxdepth 1 -type d -regex ".*/libs-.*" ! -regex "./libs-2\.2\.0-.*"
! <expr>
- 逻辑否定运算符,如果 <expr>
是 False
,则给出 True
如何为 return 所有文件夹指定正则表达式,但其名称中包含特定版本
比如我有这样的结构:
/tmp
|->java-1.9
|->libs-2.2.0-prebuild
| |-some content
|->libs-2.2.1-prebuild
| |-some content
|->libs-2.1.2-prebuild
| |-some content
我需要获取所有 libs 文件夹名称 Unix 的查找命令,但名称中包含特定版本的文件夹除外 (f.g.2.2.0)
我正在尝试这个命令,但它不起作用
find /tmp/ -maxdepth 1 -type d -regex '.*libs-((?!2\.2\.0).)*'
find
解法:
find /tmp/ -maxdepth 1 -type d -regex ".*/libs-.*" ! -regex "./libs-2\.2\.0-.*"
! <expr>
- 逻辑否定运算符,如果<expr>
是False
,则给出
True