Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to edit a file with SED?

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

accessToken=

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

accessToken=abcd123

How do I edit the file in docker with SED?

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading