X-zcer / PIT-with-RTS

0 stars 0 forks source link

(三十二)sed命令在文件中包含某个关键字的指定行的上面或下面插入内容 #32

Open X-zcer opened 6 years ago

X-zcer commented 6 years ago
  1. 在包含某个关键字的行上面插入一行文字,命令如下:

sed -i '/hello/i\1234' testfile

执行完命令后,会将i后面反斜杠后面的内容插入到包含hello关键字行的上面

  1. 在包含某个关键字的行下面插入一行文字,命令如下:

sed -i '/hello/a\4567' testfile

执行完命令后,会将a后面反斜杠后面的内容插入到包含hello关键字行的下面

X-zcer commented 6 years ago

sed -i '//a\org.apache.maven.pluginsmaven-surefire-plugin2.19.1' pom.xml

X-zcer commented 6 years ago

sed -i '/<plugins>/a\<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.19.1</version></plugin>' pom.xml