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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:51:05+00:00 2026-05-24T20:51:05+00:00

I am updating a C shell script that uses a sed command: sed ‘/EOF/r

  • 0

I am updating a C shell script that uses a sed command:

sed '/EOF/r $thingToAdd' $fileToAddItTo > $newFileOutput

I can’t seem to find what the /r command means or does. I think it is for a find and replace (similar to /s..../g).

Any ideas?

  • 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-05-24T20:51:06+00:00Added an answer on May 24, 2026 at 8:51 pm

    r is used to read a file and append it at the current point.

    The point in your example is the address /EOF/ which means this script will find the line containing EOF and then append the file specified by $thingToAdd after that point. Then it will process the rest of the file.

    In other words:

    $fileToAddItTo  +  $thingToAdd  =  $newFileOutput
    --------------     -----------     --------------
    1                  5               1
    2                  6               2
    3                                  3
    EOF                                EOF
    4                                  5
                                       6
                                       4
    

    You can see this in action in the following transcript:

    pax$ cat file1 ; echo === ; cat file2
    file1_line:1
    file1_line:2
    file1_line:3
    file1_line:4 EOF
    file1_line:5
    ===
    file2_line:1
    file2_line:2
    
    pax$ sed '/EOF/r file2' file1
    file1_line:1
    file1_line:2
    file1_line:3
    file1_line:4 EOF
    file2_line:1
    file2_line:2
    file1_line:5
    

    And, in response to the question in your comment about whether it will do this for every line containing the EOF string, yes it will:

    pax$ cat file1 ; echo === ; cat file2
    file1_line:1
    file1_line:2 EOF
    file1_line:3
    file1_line:4 EOF
    file1_line:5
    ===
    file2_line:1
    file2_line:2
    
    pax$ sed '/EOF/r file2' file1
    file1_line:1
    file1_line:2 EOF
    file2_line:1
    file2_line:2
    file1_line:3
    file1_line:4 EOF
    file2_line:1
    file2_line:2
    file1_line:5
    

    And, it will do it for every line containing the EOF string. Normally you would restrict something like this to lines containing only the EOF string since that’s usually how it’s set up (with the EOF being the only contents of that line). You could do that simply by changing the address to /^EOF$/ (the ^ and $ are the start-of-line and end-of-line anchors respectively).

    Otherwise it would pick up lines you might not expect, like those containing HEREOF, WRITEOFF or NEOFACISM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem updating a value of a variable in a shell script
I'm updating an old piece of code that uses VBScript to pull up a
Does updating statistics cause tables to be inaccessible? In other words, can you run
Need a makefile dependency rule that can handle missing files gives some pointers on
Updating a column that is part of your selection criteria should be no problem
Since updating to Lion I can't install configuration profiles with the iPhone Configuration Utility
I am trying to execute shell command through my code for adding entry in
I'm updating a Makefile that accesses some resources from an external source, i.e. there
I'm looking for a suite of plugins that can help me finally switch over
I have created a Python script that I want to run daily via a

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.