Add line at the end of the file with the command sed

0

I'm setting up a virtual machine to install JDK 7, Tomcat 7, JBoss EAP 7 and Postgresql. Follow the project on GitHub for those who are interested: cresol-enviroment-vagrant .

I'm in the part where you need to add JAVA_HOME to the file /etc/profile , but when executing the following command:

  

sudo sed -i 'JAVA_HOME = / usr / lib / jvm / jdk7u79' / etc / profile

You are returning the error message:

  

sed: -e expression # 1, char 1: unknown command: 'J'

How can I do to correctly add rows that relate to the JDK directory path?

References:

JDK 7 Installation and Configuration

    
asked by anonymous 14.12.2016 / 19:20

3 answers

2

You can also solve this problem without using sed :

sudo echo $JAVA_HOME=/usr/lib/jvm/jdk7u79 >> /etc/profile
    
17.12.2016 / 15:27
1
sudo sed -i -e '$aJAVA_HOME=/usr/lib/jvm/jdk7u79' /etc/profile
    
17.12.2016 / 15:09
0
  

You can do something like this:

echo 'JAVA_HOME=/usr/local/java
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH' >> /etc/profile
  

See more in my gist script .

    
12.06.2017 / 08:37