skip to Main Content

Replace same occurrence of word with different words using sed – CentOS

I want to replace 2 same words in file(app.properties) with 2 different words using sed command. Example: mysql.host=<<CHANGE_ME>> mysql.username=testuser mysql.port=3306 mysql.db.password=<<CHANGE_ME>> required output will be mysql.host=localhost mysql.username=testuser mysql.port=3306 mysql.db.password=password123 I tried below command: sed -e "s/<<CHANGE_ME>>/localhost/1" -e "s/<<CHANGE_ME>>/password123/2" app.properties >…

VIEW QUESTION

SED pattern matching – Nginx

I am trying to modify NGINX config file using sed. I wand to replace the values of ssl_certificate and ssl_certificate_key config="/etc/nginx/httpd.conf" certfile="server.pem" keyfile="key.pem" sed -i -e "s/(ssl_certificate */etc/pki/nginx/).*/1$certfile/" $config sed -i -e "s/(ssl_certificate_key */etc/pki/nginx/private/).*/1$keyfile/" $config With the starting lines that…

VIEW QUESTION

Redis – How to properly use regex to search from a command's output in Bash?

I have a command lando info which has a fairly large multi-line output: [ { service: 'appserver', urls: [ 'https://localhost:52836', 'http://localhost:52837', 'http://if-build-d9.lndo.site/', 'https://if-build-d9.lndo.site/' ], type: 'php', healthy: true, via: 'apache', webroot: './web', config: { php: '/Users/runo/.lando/config/drupal9/php.ini' }, version: '7.3', meUser:…

VIEW QUESTION
Back To Top
Search