Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 在bash中使用find命令的正则表达式_Regex_Bash_Find - Fatal编程技术网

Regex 在bash中使用find命令的正则表达式

Regex 在bash中使用find命令的正则表达式,regex,bash,find,Regex,Bash,Find,我一直在尝试在bash中使用带有find命令的正则表达式。以下是我的密码: find . -regextype posix-extended -regex 'AB[0-9]{1}_all_chr\.gz' 但是,上述代码与id为“AB1_all_chr.gz”和“AB2_all_chr.gz”的所需文件不匹配。有人能帮我解决这段代码吗 因此,要提供一个实际的答案: find-regextype posix extended-regex'^.*AB[0-9]\u all\u chr\.gz$'

我一直在尝试在bash中使用带有find命令的正则表达式。以下是我的密码:

find . -regextype posix-extended -regex 'AB[0-9]{1}_all_chr\.gz'

但是,上述代码与id为“AB1_all_chr.gz”和“AB2_all_chr.gz”的所需文件不匹配。有人能帮我解决这段代码吗

因此,要提供一个实际的答案:

find-regextype posix extended-regex'^.*AB[0-9]\u all\u chr\.gz$'


匹配开头的任何文本,后跟
AB
,然后是任何一个数字,最后是
\u all\u chr.gz

需要
*
在开始时,需要匹配整个路径。另外,
[0-9]{1}
是冗余的
[0-9]
已经执行了一个字符。请参阅,谢谢,它成功了!