Home > Blockchain >  remove the line from the file and add the another entry in same position using sed
remove the line from the file and add the another entry in same position using sed

Time:07-14

One of the parameter into the property file is JAVA_HOME=/var/tmp/java/jdk1.x.x planning to remove entire line of JAVA_HOME and add the new JAVA_HOME=/var/tmp/java/jdk11.0.5 into the same like of the property file using SED command.

ex:Remove the line 3 and add the JAVA_HOME=/var/tmp/java/jdk11.0.5 into the same location line 3.

#!/bin/sh
export ORACLE_HOME=/opt/ibm/oracle
export JAVA_HOME=/var/tmp/java/java1.8.0.31

CodePudding user response:

Backup the original file and try this sed command:

sed -i 's%JAVA_HOME=.*%JAVA_HOME=/var/tmp/java/jdk11.0.5%' file
  • Related