when cp -r jdk1.8.0_331 /usr/java
in command line, it results in such a folder:
# ls /usr/java/jdk1.8.0_331/
bin COPYRIGHT include javafx-src.zip jmc.txt jre legal lib LICENSE man README.html release src.zip THIRDPARTYLICENSEREADME-JAVAFX.txt THIRDPARTYLICENSEREADME.txt
However, once I put it in a shell script and run in remote host, ssh root@app-1 < java_install.sh
,
it results in such a folder:
# ls /usr/java/
bin COPYRIGHT include javafx-src.zip jmc.txt jre legal lib LICENSE man README.html release src.zip THIRDPARTYLICENSEREADME-JAVAFX.txt THIRDPARTYLICENSEREADME.txt
One layer off. Why? And how can I copy a folder into another folder as a child folder in remote shell script?
This is the whole script:
#!/bin/bash
tar -zxvf jdk-8u331-linux-x64.tar.gz
cp -r jdk1.8.0_331 /usr/java
echo '
export JAVA_HOME=/usr/java/jdk1.8.0_331
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
' >> /etc/profile
source /etc/profile
java -version
And I have just found that, when running script twice, the second time, it moves jdk1.8.0_331 to /usr/java/jdk1.8.0_331.