Home > Back-end >  How to edit a file with SED?
How to edit a file with SED?

Time:08-10

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?

CodePudding user response:

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

CodePudding user response:

sed -i /s/testtobechanged/textwanted/g applications.proteries
  • Related