2017-04-18 154 views
-1

我一直試圖在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」。有人可以幫我解決這段代碼嗎?

+3

需求'結束*'在開始,你需要整個路徑進行匹配。另外'[0-9] {1}'是多餘的'[0-9]'已經做了一個字符。 – 123

+0

請參閱[如何使用正則表達式與find命令?](http://stackoverflow.com/questions/6844785/how-to-use-regex-with-find-command) –

+0

謝謝,它的工作! –

回答

0

因此,爲了提供一個實際的答案:

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

比賽一開始,隨後AB,然後任何一個數字的任何文本,然後用_all_chr.gz