终端调用函数
在HOME目录下的profile文件中定义函数,可以直接调用
[root@localhost ~]# vim $HOME/.profile
#!/bin/bash
function tomcat(){
param=$1
case $param in
"start")
/usr/local/tomcat8.0.39/bin/startup.sh
;;
"stop")
/usr/local/tomcat8.0.39/bin/shutdown.sh
;;
"restart")
/usr/local/tomcat8.0.39/bin/shutdown.sh
/usr/local/tomcat8.0.39/bin/startup.sh
;;
*) echo "please exec right command"
;;
esac
}
[root@localhost ~]# source $HOME/.profile #使文件立即生效
[root@localhost tomcat8.0.39]# tomcat start(参数)
Using CATALINA_BASE: /usr/local/tomcat8.0.39
Using CATALINA_HOME: /usr/local/tomcat8.0.39
Using CATALINA_TMPDIR: /usr/local/tomcat8.0.39/temp
Using JRE_HOME: /usr/local/jdk1.8.0_111/jre
Using CLASSPATH: /usr/local/tomcat8.0.39/bin/bootstrap.jar:/usr/local/tomcat8.0.39/bin/tomcat-juli.jar
Tomcat started.