linux - How to modify /etc/environment from a bash script -


Currently, I am trying to automate an action that we do at work. Whenever we install the Oracle's JDK, we need to manually add it to our global PATH variable. There is a quote from this process:

  add it to the beginning of sudo vi / etc / environment path: "/opt/jdk1.6.0_45/bin:"   / etc / environment  is here:  
  PATH = "/ usr / local / sbin: / usr / local / bin: / usr / sbin: / Usr / bin: / sbin: / bin: / usr / games "  

It will appear after its modification:

  path =" / opt / jdk1 .6.0_45 / bin: / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin: / usr / games "  < P> Do not forget that this file is not a script but rather a file Where key = value is. This file stores system-wide locale and path settings.  

My question is I PATH variable with / etc / environment without including any manual operation, preferably only Using a Bash script. Besides, I would like to avoid seeing my JDK path, if I have run the script twice as a result. P> You can use sed to remove it for the first time and then insert the jdk path:

  #! / Bin / bash sed -e's /opt/jdk1.6.0_45/bin: || G '-i / etc / Environment SAD' s | Path = "\ (. * \)" | PATH = "/ opt / jdk1.6.0_45 / bin: \ 1" | G "-i / etc / environment    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -