我有一个带有一段代码的 fileA,我需要一个脚本将该代码段插入到 fileB 中特定模式之后的行中。
我正在尝试使该线程中接受的答案起作用,但事实并非如此,也没有给出错误,所以不知道为什么不:
sed -e '/pattern/r text2insert' filewithpattern
有什么建议么?
模式(在后面插入代码段):
def boot {
也尝试了转义模式,但没有运气:
def\ boot\ {
def\ boot\ \{
文件片段:
LiftRules.htmlProperties.default.set((r: Req) =>
new Html5Properties(r.userAgent))
文件B(引导.scala):
package bootstrap.liftweb
import net.liftweb._
import util._
import Helpers._
import common._
import http._
import sitemap._
import Loc._
/**
* A class that's instantiated early and run. It allows the application
* to modify lift's environment
*/
class Boot {
def boot {
// where to search snippet
LiftRules.addToPackages("code")
// Build SiteMap
val entries = List(
Menu.i("Home") / "index", // the simple way to declare a menu
// more complex because this menu allows anything in the
// /static path to be visible
Menu(Loc("Static", Link(List("static"), true, "/static/index"),
"Static Content")))
// set the sitemap. Note if you don't want access control for
// each page, just comment this line out.
LiftRules.setSiteMap(SiteMap(entries:_*))
// Use jQuery 1.4
LiftRules.jsArtifacts = net.liftweb.http.js.jquery.JQuery14Artifacts
//Show the spinny image when an Ajax call starts
LiftRules.ajaxStart =
Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)
// Make the spinny image go away when it ends
LiftRules.ajaxEnd =
Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd)
// Force the request to be UTF-8
LiftRules.early.append(_.setCharacterEncoding("UTF-8"))
}
}