对于给定的文件-
TEST_File
----------
<At_First_Sight> <isCalled> "A.
<The_Godfather> <isCalled> "A.
<The_Godfather> <isCalled> "Mrr.
<Night_of_the_Comet> <type> "wikicategory_Comedy_science_fiction_films".
Required output should be -
<Night_of_the_Comet> <type> "wikicategory_Comedy_science_fiction_films".由于这已经结束了doublt quotes.Also,您可以假设s行中不会有超过2个双引号。
Command - ^(.+?\"[^\"]+\.)似乎是在基于web的regex检查器上工作,而不是在bash上工作。
发布于 2014-04-15 17:06:05
用白鹭更容易:
egrep '^[^"]*"[^"]*$' file
<At_First_Sight> <isCalled> "A.
<The_Godfather> <isCalled> "A.
<The_Godfather> <isCalled> "Mrr.如果您想要sed,那么使用:
sed -n '/^[^"]*"[^"]*$/p' filehttps://stackoverflow.com/questions/23090093
复制相似问题