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 7709553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:53:29+00:00 2026-06-01T00:53:29+00:00

I am trying to script the automatic input of file, which is as follows

  • 0

I am trying to script the automatic input of file, which is as follows

*CONTACT_FORMING_ONE_WAY_SURFACE_TO_SURFACE
$#     cid                                                                 title
$#    ssid      msid     sstyp     mstyp    sboxid    mboxid       spr       mpr
     1         2         3         3         0         0         0         0
$#      fs        fd        dc        vc       vdc    penchk        bt        dt
0.0100          0.000     0.000     0.000     0.000         0     0.000 1.0000E+7
$#     sfs       sfm       sst       mst      sfst      sfmt       fsf       vsf
1.000000  1.000000     0.000     0.000  1.000000  1.000000  1.000000  1.000000
*CONTACT_FORMING_ONE_WAY_SURFACE_TO_SURFACE
$#     cid                                                                 title
$#    ssid      msid     sstyp     mstyp    sboxid    mboxid       spr       mpr
     1         3         3         3         0         0         0         0
$#      fs        fd        dc        vc       vdc    penchk        bt        dt
0.0100          0.000     0.000     0.000     0.000         0     0.000 1.0000E+7
$#     sfs       sfm       sst       mst      sfst      sfmt       fsf       vsf
1.000000  1.000000     0.000     0.000  1.000000  1.000000  1.000000  1.000000

I want to changed fifth line after the string

 *CONTACT_FORMING_ONE_WAY_SURFACE_TO_SURFACE

with a line from other file frictionValues.txt

What I am using is as follows

sed -i -e '/^\*CONTACT_FORMING_ONE_WAY_SURFACE_TO_SURFACE/{n;n;n;n;n;R frictionValues.txt' -e 'd}' input.txt

but this changes all the 5 lines after the string but it reads the values 2 times from the file frictionValues.txt. I want that it reads only first line and then copy it at all the instance where it finds the string. Can anybody tell me using sed with inplace editing like this one?

  • 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-01T00:53:31+00:00Added an answer on June 1, 2026 at 12:53 am

    This might work for you (I might be well off the mark as to what you want!):

    sed '1s|.*|1{x;s/^/&/;x};/^\*CONTACT_FORMING_ONE_WAY_SURFACE_TO_SURFACE/{n;n;n;n;n;G;s/.*\\n//}|;q' frictionValues.txt |
    sed -i -f - input.txt
    

    Explanation:

    • Build a sed script from the first line of the frictionValues.txt that stuffs the said first line into the hold space (HS). The remaining script is as before but instead of R frictionValues.txt appends the HS to the pattern space using G.
    • Run the above sed script against the input.txt file using the -f - switch the sed script is passed via stdin from the previous pipeline.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to create a script that opens a file and replace every 'hola'
I am trying to use an automated script, which would login to SVN, update
I am trying to make a simple script to automate and log synchronization via
I'm trying to script the shutdown of my VM Servers in a .bat. if
I get this error when trying ruby script/console Rails requires RubyGems >= . Please
I'm playing around with the Win32::IE::Mechanize. I'm trying a script to automatically access six
I find it much easier to write MXML classes with embedded Script than trying
I've Google around and haven't found much... I'm trying to run script/server for my
Im trying to add a Jquery validation script to a form plugin for wordpress.
I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but

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.