skip to Main Content

I am running docker on a Virtual Machine on an Amazon AWS EC2 instance and I want to edit one file (application.properties) which lies in the following directory:

root@e2afc27e858e:/score-client/conf/applications.proteries

The docker image does not seem to contain vim/vi, nano or emacs. That’s why I should edit the file with "sed".

In particular, in the application.properties file is a line called:

accessToken=

But I want to edit the file so that it says:

accessToken=abcd123

How do I edit the file in docker with SED?

2

Answers


  1. sed -i /s/testtobechanged/textwanted/g applications.proteries
    
    Login or Signup to reply.
  2. Given the following application.properties example file

    toto="some value"
    accessToken="atoken"
    pipo="other value"
    bingo=1
    

    the following sed command:

    sed -i 's/^(accessToken=).*$/1"abcd123"/' application.properties
    

    gives as a result (i.e. cat application.properties)

    toto="some value"
    accessToken="abcd123"
    pipo="other value"
    bingo=1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search