我有三种类型的文件
ABC.A10B
ABC_random.A2B
ABC_test.A14B
我想找到所有类型1和类型2的文件。我只需要XXXYYY_test.A1B
类型3
我编写了以下bash命令来执行此操作
find . -name "*.A[1-9]*B" ! -name "*_test.A[2-9][0-9]*B"
但是上面的命令会打印所有*_test.A[0-9]*B
个文件。
在bash
中打印类型1,2和类型3的*_test.A1B
的正确方法是什么?
答案 0 :(得分:0)
如果你有find
的gnu版本,那么你可以像这样使用find
:
find . -regextype posix-extended -type f -regex '.*\.A[1-9][0-9]*B$'
如果你在OSX上,那么使用:
find -E . -type f -regex '.*\.A[1-9][0-9]*B$'