linux centos 编写sh文件,CentOS下shell脚本编写实例

  • Post author:
  • Post category:linux


#!/bin/bash

#安装jdk

echo “选择Y开始 N结束,中断的话选择Ctrl+C”

echo -n “select Y or N:”

read NAME

if [ “$NAME” = “N” ]

then

echo “N 退出”

else

#执行安装tomcat

#find / -name apache-tomcat-6.0.18.tar.gz > ./aaa

#tar -zxvf `cat ./aaa`

#mkdir /opt/tomcat

#find / -name apache-tomcat-6.0.18 > /la

#echo “Torture fatigued jakarta-tomcat-5.0.28/ in course of waiting for one meeting to opt/tomcat/, please”

#cp -r `cat /la`/* /opt/tomcat

#装JDK

#find /home/ken/Desktop -name jdk-1_5_0_19-linux-i586-rpm.bin > /aaa

#chmod a+x `cat /aaa`

#cp `cat /aaa` /

#cd /

#./jdk-1_5_0_19-linux-i586-rpm.bin

#rm -rf /aaa

#mkdir /usr/jdk

#cp -r /j2sdk1.4.2/* /usr/jdk

#rm -rf /j2sdk1.4.2 /j2sdk-1.4.2-03-linux-i586.bin

#mv /etc/profile /etc/zuan

mv /home/ken/Desktop/profile /home/ken/Desktop/zuan

sed ‘s/export/& JAVA_HOME CLASS_PASS TOMCAT_HOME /’ /home/ken/Desktop/zuan>/home/ken/Desktop/yirehe

sed ‘/local/a pathmunge /usr/jdk/bin’ /home/ken/Desktop/yirehe>/home/ken/Desktop/ewang

sed ‘/LOGNAME=$USER/a\CLASS_PATH=”/usr/jdk/lib/tools.jar” JAVA_HOME=”/usr/jdk/” TOMCAT_HOME=”/opt/tomcat/”‘ /home/ken/Desktop/ewang>/home/ken/Desktop/profile

#rm -rf /etc/zuan /etc/yirehe /etc/ewang

fi