Find the answer to your Linux question:
Results 1 to 4 of 4
Here the question. orion-web.xml is a file which has mode nodes of which <webapp> </webapp> is one of the it. How can we add <session-config> <session-timeout>-1s</session-timeout> <session-config> Here is the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    2

    Unhappy how to append additional lines in an another file


    Here the question.
    orion-web.xml is a file which has mode nodes of which
    <webapp>
    </webapp>
    is one of the it.

    How can we add
    <session-config>
    <session-timeout>-1s</session-timeout>
    <session-config>

    Here is the resolution which is not working,
    echo "<session-config>\n" > /tmp/somefile
    echo "<session-timeout>-1s</session-timeout>\n" >> /tmp/somefile
    echo "<session-config>\n" >> /tmp/somefile

    sed -i "<webapp>/r /tmp/somefile" orion-web.xml

  2. #2
    Just Joined! ford's Avatar
    Join Date
    Jan 2011
    Location
    GA, USA
    Posts
    25
    ">" will dump to file, overwriting anything there
    ">>" will append to file, but at the very end

    so, you could do:
    cat >> ~/your_file << "EOF"
    <session-config>
    <session-timeout>-1s</session-timeout>
    <session-config>
    EOF

  3. #3
    Just Joined!
    Join Date
    Aug 2010
    Posts
    2

    Unhappy

    Sorry can you please illustrate with actual commands what you mean to say?

    Thanks

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by bluemind2005 View Post
    Sorry can you please illustrate with actual commands what you mean to say?

    Thanks
    He did. The command he used is cat. His example uses cat to append everything inside the two EOF statements to the end of the file named ~/yourfile.

    One issue: your session-config parameter needs to have a closing "/" at the beginning of the parameter name, in order to "close" the node.

    I'm not entirely clear what you want your XML to look like, is it something like this?

    Code:
    <webapp>
      <session-config>
        <session-timeout>-1s</session-timeout>
      </session-config>
    </webapp>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •