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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:46:46+00:00 2026-06-18T05:46:46+00:00

In my code, I need to replace variable assignments with addresses: sed -i s/^variable

  • 0

In my code, I need to replace variable assignments with addresses:

sed -i "s/^variable = .*$/variable = http://myaddress/"

Obviously, this does not work because the forward slashes in the address are recognized in the sed command.

I want to keep the $ at the end of the first expression for replacing anything to the end of the line. I also do not want to escape the dollar sign as such, \$ because it will search for a dollar sign.

Also, I don’t want to just escape the forward slashes in the address as there are also variables in some places for the addresses.

I’ve tried using # instead of / but have to include what I don’t want to – the \$.

Are there any alternate delimiters I can use that fit my situation?

  • 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-18T05:46:48+00:00Added an answer on June 18, 2026 at 5:46 am

    The $ is interpreted by your shell. Wrap the whole argument to sed with ' to prevent this.

    sed -i 's#^variable = .*$#variable = http://myaddress#'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to replace a string in certain documents. I have googled this code,
I need to replace integer variable to factor using this statement below I can
This is what I am trying to accomplish: location.replace('http://localhost:8888/test/index.php?site=' + document.URL); So I need
I need to add to Javascript replace function a variable. This example works fine:
I need PHP code to replace comma or whitespace with hyphen For eg: If
I am trying to unit test some code, and I need to to replace
Using C#, I need a some code to use regular expressions to replace spaces
I don't really know XSL but I need to fix this code, I have
This is similar to Using sed to replace beginning of line when match found
I have the following code which works fine but i need to replace the

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.