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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:19:12+00:00 2026-05-16T12:19:12+00:00

I have to extract a parameter from a configuration file, and replace its values

  • 0

I have to extract a parameter from a configuration file, and replace its values with another given value.
The config file is:

<host ip="200.200.200.200" name="testhost" description="test server" type="TEST_Duplex " connection="xmlrpc" xmldefaulttimeout="2.0" xmlspecifictimeout ="8.0"/>

I have to replace the value of xmldefaulttimeout="2.0" with another value, for example: xmldefaulttimeout="4.0".

As in the text, xmldefaulttimeout=”2.0″, but in fact, the value “2.0” is not certain. It may be another uncertain value. So I have to grep the value of xmldefaulttimeout and replace it with another given value (for example:4.0).

I think I have to use sed or awk. But I’m sorry my tried commands can’t realize this.
Could anybody help me with this? Thanks!
I’m sorry I just begin to learn shell:-)

  • 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-16T12:19:13+00:00Added an answer on May 16, 2026 at 12:19 pm
    input='<host ip="200.200.200.200" name="testhost" description="test server" type="TEST_Duplex " connection="xmlrpc" xmldefaulttimeout="2.0" xmlspecifictimeout ="8.0"/'
    
    new_value='xmldefaulttimeout="4.0"'
    
    echo $input | sed "s/xmldefaulttimeout=\"[0-9.]*\"/$new_value/"
    

    To match any value for xmldefaulttimeout you’ll have to use a regex: xmldefaulttimeout=\"[0-9.]*\"

    • xmldefaulttimeout= : Matched
      literally
    • \" : To match a literal ", you need
      to escape the " to prevent
      premature ending of the pattern.
    • [0-9.] : Char class to match any
      digit or a period
    • * : zero or more of the previous char.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to extract columns from a text file explained in this post: Extracting
I have the following URL from which I want to extract the id parameter:
I have a problem where I need to extract a query string parameter from
I'm using Selenium for work and I have extract some data from //ul, unfortunately
I have to extract defined variable and function names from a js code passed
I've a requirement where I have to extract metrics from different Java projects (configured
I have been trying to extract an e-mail address from a website using XPath.
I have been trying to extract e-mail addresses from the following code for quite
I have been trying to extract data from a database and fill in a
I have an auto-generated file which looks something like this... static void do_SomeFunc1(void* parameter)

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.