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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:08:46+00:00 2026-06-10T10:08:46+00:00

I can’t get a simple regex replacement to work with sed. Here is the

  • 0

I can’t get a simple regex replacement to work with sed. Here is the example I’m faced with.

I am trying to replace lines in a file, from this:

select * from mytable where mytable.s_id=274
select * from mytable where mytable.s_id=275
select * from mytable where mytable.s_id=276
select * from othertable where othertable.id=?
select * from table3 where table3.name=?

to this:

select * from mytable where mytable.s_id=?
select * from mytable where mytable.s_id=?
select * from mytable where mytable.s_id=?
select * from othertable where othertable.id=?
select * from table3 where table3.name=?

I am using sed as such for now:

cat log | sed 's/where mytable\.s_id=[0-9]+/where mytable.s_id=/g' | sort

But the regex I am using in sed ('s/where mytable\.s_id=[0-9]+/where mytable.s_id=/g') doesn’t replace anything.

I am reading as much documentation as I can, but everything I read is different, with different way of doing things so I am a little lost. What is the canonical way for a regex replacement using sed, and what would it look like in my particuliar case?

Note: I simplified the problem I’m facing. I do want to use sed (to finally learn to use it) and I do want to pipe the input and output (not editing the file in place) because the command line I use is actually more complicated than that.

  • 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-10T10:08:47+00:00Added an answer on June 10, 2026 at 10:08 am
    cat log | sed 's/where mytable\.s_id=[0-9]\+/where mytable.s_id=?/g'
    

    Just a backslash before the +.

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

Sidebar

Related Questions

Can anyone help me trying to find out why this doesn't work. The brushes
Can I get a big picture for graph objects? Example: //take id,name,picture,description from pages,
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can we change the default action of the edit selected row button? Here is
I have just tried to save a simple *.rtf file with some websites and
Can anyone give me an example of how to return the following json simply
Can anybody shed some light on getDay() in Javascript please. Here datepicker is textbox
I am trying to render a haml file in a javascript response like so:
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object

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.