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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:23:04+00:00 2026-06-06T10:23:04+00:00

I’m having a problem using the sed substitution option that executes a command in

  • 0

I’m having a problem using the sed substitution option that executes a command in the replacement pattern. I believe the option is an extensions to GNU sed but I haven’t been able to find any documentation on it. Anyone know of any?

My problem is that I can’t extract the matching text properly when using the execute replacement option. I’m using GNU sed 4.2 on Mac OSX 10.7.4

echo "12345678\r" | sed 's/.*/echo "&);"/e'

Result: );345678
Desired Result: 12345678);

I’ve tried using different regex matches, such as \d+, but that just seems to break the ability to use the /e substitution option. And I’ve tried using an explicit capture group such as \1 instead of & but that also seems to break the /e option.

Update:

My example was perhaps oversimplified what I’m ultimately trying to do is take a text file with each line holding a unique value and pass that to sed and use the uuidgen command (in the same manner as a previous question I posted). The new problem I’ve got is because I’m now running the command on a Mac the \r is not being stripped from the matched string.

The full command I want to execute is:

sed 's/.*/echo "blah blah `uuidgen`,&):"/e' file.txt

Update 2:

In my Mac terminal I don’t need to use echo -e to get \r interpreted as a line feed and in fact according to “man echo” there is no -e option. It does make life difficult moving between all the terminal environments :(.

Thanks to kev I was able to come up with a solution that worked on Mac.

sed 's/\r//; s/.*/ echo "blah blah (`uuidgen`,&);"/e' file.txt
  • 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-06T10:23:05+00:00Added an answer on June 6, 2026 at 10:23 am

    Remove the e flag:

    $ echo "12345678\r" | sed 's/.*/echo "&);"/'
    echo "12345678\r);"
    

    Add e flag is the same as:

    $ echo -e "12345678\r);"
    );345678
    

    You can remove the \r:

    $ echo "12345678\r" | sed -e 's/\\r//' -e 's/.*/echo "&);"/'
    12345678);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping 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.