当前directoy中file_root之后具有2个精确下划线的文件

时间:2016-01-22 01:09:01

标签: linux bash find

我希望在file_root之后找到带有2个下划线的文件,如下所示:

file_root_stringA_stringB.txt

其中stringA和stringB都在alnum类

find /tmp -maxdepth 2 -type f -name "file_root_*_*.txt"

但我坚持:

file_root_aaa_bbb.txt # expected
file_root_aaa_bbb_c12.txt # not expecting

我怎样才能在bash中获得这个?感谢

2 个答案:

答案 0 :(得分:2)

find /tmp -maxdepth 2 -type f -name "file_root_*_*.txt" -not -name "file_root_*_*_*.txt"

答案 1 :(得分:1)

您可以使用正则表达式:

grepl("^D ", txt_obj)
相关问题