regex - 使用 bash 计算子树中特定目录的数量

标签 regex linux bash unix find

所以,我有一个应该采用以下格式的目录树:

 ~/root/dir.abc/
 ~/root/dir.adc/

我想确保两个目录都存在

我试过了

 find ~/root -type d -regex "\S*\.a(b|d)c"

为此却无济于事。我该怎么做呢?

 find ~/root -type d -name *.abc
 find ~/root -type d -name *.adc

可以提供我想要的东西,并在其中添加一些额外的东西,但我只想尽可能缩小到一行。

最佳答案

找到解决方案:

find ~/root -type d -path "*/dir.a[bd]c"

关于regex - 使用 bash 计算子树中特定目录的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47227160/

相关文章:

regex - 使用 linux grep 查找电子邮件

windows - 如何阻止 socat 退出?

linux - 如何获得永久MAC地址

bash:列出不具有给定扩展名的文件

linux - 如何在 shell 脚本中加入 2 个变量?

javascript - 如何在 RegEx 中分割可选参数?

ruby - 从文本 block 中提取电子邮件地址

bash - 为什么 ack over ssh 不起作用?

regex - 从字符串中提取 n-decimal

linux - 如何将库链接到执行文件