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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:46:13+00:00 2026-06-16T13:46:13+00:00

I am stumped on why this sed command would not be working: sed ‘s/<script

  • 0

I am stumped on why this sed command would not be working:

sed 's/<script id="live-reload"[\s\S]*?<\/script>/test/g' www_public/index.html > www_public/index.html.temp

It should replace the live-reload script tag of the following HTML with ‘test’:

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>

        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>AssembleJS</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">

        <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
        <link rel="stylesheet" href="assets/css/main.css">

    </head>

    <body>

        <script id="require-lib" data-main="src/config" src="src/libs/require.js"></script>

        <script id="live-reload">document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>

        <script id="test"> bla bla bla </script>

    </body>

</html>

Here’s the regex working:

http://regexr.com?339ga

  • 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-16T13:46:14+00:00Added an answer on June 16, 2026 at 1:46 pm

    You need to use -r for ? as it’s extended regex:

    $ sed -r 's/<script id="live-reload".*?<\/script>/test/g' file
    

    or escape it:

    $ sed 's/<script id="live-reload".*\?<\/script>/test/g' file
    

    Output:

    <!DOCTYPE html>
    <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
    <!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
    <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
        <head>
    
            <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
            <title>AssembleJS</title>
            <meta name="description" content="">
            <meta name="viewport" content="width=device-width">
    
            <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
            <link rel="stylesheet" href="assets/css/main.css">
    
        </head>
    
        <body>
    
            <script id="require-lib" data-main="src/config" src="src/libs/require.js"></script>
    
            test
    
            <script id="test"> bla bla bla </script>
    
        </body>
    
    </html>
    

    Notes:

    • Also changed [\s\S]*? to .*? as they’re complimentary groups.

    • The g flag is only necessary for multiple matches on a single line.

    • If you’re running Mac the -r flag is -E so check with sed
      --help
      for the extended regex option.

    • Obligatory don’t parse [x]html with regex warning, using a parser.

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

Sidebar

Related Questions

I'm stumped by this seemingly trivial problem... I would like to use python to
I am stumped on this and I need some fresh eyes, I'm not sure
I'm a little stumped on this one and I'm also not still on 1.8
I'm reviewing for a test, and I am stumped by this question. Consider the
I'm stumped with this one and your help would be most appreicated. I get
I've been stumped with this for a while now. I'm working on an android
I'm working with dates in php and I'm a little stumped This is my
I am totally stumped on this one. I am getting a Object reference not
Im stumped by this simple query because its one I have not tried before.
Stumped at this part. I have a simple html input, and a jquery ui

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.