【发布时间】:2014-10-21 22:28:10
【问题描述】:
有没有办法使用扩展正则表达式来查找以字符串结尾的特定模式。
我的意思是,我想匹配前 3 行而不是最后一行:
file_number_one.pdf # comment
file_number_two.pdf # not interesting
testfile_number____three.pdf # some other stuff
myfilezipped.pdf.zip some comments and explanations
我知道在 grep 中,元字符 $ 匹配行尾,但我对匹配行尾不感兴趣,而是匹配字符串尾。 grep 中的分组很奇怪,我还不太了解。
我尝试了组匹配,实际上我有一个类似的正则表达式,但它不适用于 grep -E
(\w+).pdf$
有没有办法在 grep/egrep 中进行字符串结尾匹配?
【问题讨论】: