我想删除所有pom.xml文件中的maven依赖项。我知道如何删除指定行之后的行,但不知道如何删除指定行之前的行。
<dependency>
<groupId>moon</groupId>
<artifactId>conup-remote-configuration</artifactId>
<version>0.9.1-DU-SNAPSHOT</version>
</dependency>发布于 2014-08-07 11:56:31
也许您可以向后处理文件,从文件的最后一行开始,到文件的第一行结束。像tac myfile.txt | sed ... | tac myfile2.txt tac这样的东西是猫的倒退。
发布于 2014-08-07 15:36:56
这将删除命中pattern的行之前的行。
awk '!/pattern/ && NR>1 {print f} {f=$0} END {print f}' filehttps://stackoverflow.com/questions/25173627
复制相似问题