我的sed代码工作了......但我不明白为什么。有人可以帮我理解吗?

时间:2013-09-09 18:50:33

标签: design-patterns file-io sed

我试图在文件中删除不包含两个单独术语的行。我得到了它的工作,但不知道它是如何工作的。

sed -i '/^HETATM/!{/^ATOM/!d}' file
有人可以解释一下吗?

1 个答案:

答案 0 :(得分:1)

您的sed行将删除所有不以HETATMATOM

开头的行
'/^HETATM/!   #if the line is not starting with HETATM, continue to process
{/^ATOM/!d}'  #then we come here, if the line is not starting with ATOM, Del the line

我会这样写:

sed  '/^A\|^B/!d'