Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7764039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:48:42+00:00 2026-06-01T14:48:42+00:00

I have a fileA with a snippet of code, and I need a script

  • 0

I have a fileA with a snippet of code, and I need a script to insert that snippet into fileB on the line after a specific pattern.

I’m trying to make the accepted answer in this thread work, but it’s not, and is not giving an error so not sure why not:

sed -e '/pattern/r text2insert' filewithpattern

Any suggestions?

pattern (insert snippet on line after):

def boot {

also tried escaped pattern but no luck:

def\ boot\ {
def\ boot\ \{

fileA snippet:

    LiftRules.htmlProperties.default.set((r: Req) =>
        new Html5Properties(r.userAgent))

fileB (Boot.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"))

  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:48:44+00:00Added an answer on June 1, 2026 at 2:48 pm

    The sed format looks correct to me.

    To help you diagnose this, try it with two simpler text files and a simple pattern.

    File filewithpattern:

    hello
    world
    

    File textinsert:

    foo
    goo
    

    Now run sed:

    sed -e '/hello/r textinsert' filewithpattern
    

    You should see this:

    hello
    foo
    goo
    world
    

    Does that work for you?

    If so, then edit filewithpattern to use your target:

    hello
    def boot {
    world
    

    Run the command:

    sed -e '/def boot {/r textinsert' filewithpattern
    

    You should see this:

    hello
    def boot {
    foo
    goo
    world
    

    If you want variable substitution, try this:

    #!/bin/bash
    PATTERN='def boot {'
    sed -e "/${PATTERN}/r textinsert" filewithpattern
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working perl script that grabs the data I need and displays
I have the following snippet of java code: File directoryToMoveTo = new File(file.getParent()+_TEMP); boolean
I have a script snippet looks like below: <ItemGroup> <files Include=*.txt></files> </ItemGroup> <Message Text=@(files)>
I have a simple swf file upload script that uploads a file as soon
I have got a code snippet as follows: Dim fstream = new filestream(some file
I have this code snippets that generates a signature for POSTs. The detail of
I have the following code snippet which is working fine: ifstream NDSConfig( NDS.config )
I have files a1 a2 a3 b1 b2 b3 and I need to exclude
I am learning Python (I have a C/C++ background). I need to write something
I am currently developing a website and i need that the pages loads dynamically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.