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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:03:39+00:00 2026-05-26T16:03:39+00:00

here is my question , im using ubuntu , and im trying to replaces

  • 0

here is my question , im using ubuntu , and im trying to replaces text in a xml file .. from a txt that i have all changes that i made ,an example

in replace.txt file i have this

    nameofsearch  | nameforreplace
    nameofsearch1 | nameforreplace1 
    nameofsearch2 | nameforreplace2 

this is the format that the software uses for search and replace

and on the xml file, i have the nameofsearch

this was done by a soft made on .net, that i can’t run on linux , so this is my question , how can i do that , using bash , or any other thing like that.

thanks , sebastian.

  • 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-26T16:03:40+00:00Added an answer on May 26, 2026 at 4:03 pm

    The tool you are looking for is sed. If you want to replace str1 with str2 in file1 and save the result in file2, run:

    sed s/str1/str2 < file1 > file2
    

    You need to escape some special characters because sed parses the str1 as a regular expression.

    In your case, two steps are needed. The first step transforms your replace.txt into a sed script file witch I call replace.sed.

    sed "s/\s*|\s*/\//g"  "replace.txt" | sed "s/\w*\/\w*/s\/&\/g/" > replace.sed
    

    The first sed call transforms your pipes (and surrounding whitespaces) into slashes |->/. The second call surrounds your search/replace strings with sed syntax. replace.sed should look like

    s/nameofsearch/nameforreplace/
    s/nameofsearch1/nameforreplace1/
    s/nameofsearch2/nameforreplace2/
    

    The second step is to execute sed with the given script file on your xml file.

    sed -f replace.sed test.xml > replaced.xml
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my question. Right now I have a Linux server application (written using C++
So I decided to start using prototype and here's my first question. I'm trying
Basic c++ question here. I'm trying to read a large file on Windows 7
I asked a question here : When To Use IEquatable And Why about using
Right, simple question here. I couldn't find an answer using google and looking here.
This question is an extension to the one raised here: Using factory_girl in Rails
EDIT: The plugin in question is located here . PHP beginner here using a
This is probably a trivial question for most but here goes... I am using
For more info, see my other question, here . So anyway, I'm using BigDecimals
I am using the ErrorHandlingProxy from here and had a coupla questions. I noticed

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.