hello-goodby.sh
#!/bin/bash
#在当前目录下($PWD)为这个脚本创建一个链接:
#ln -s hello.sh goodbye
hello_call=65
goodbye_call=66
if [ $0 = "./goodbye" ];then
echo "good-bye!"
exit $goodbye_call
fi
echo "hello"
exit $hello_call
验证:
[root@logstash ~]# ls -l
total 4
lrwxrwxrwx 1 root root 15 Jul 26 14:18 goodbye -> hello-goodby.sh
-rwxr-xr-x 1 root root 231 Jul 26 14:20 hello-goodby.sh
[root@logstash ~]#
[root@logstash ~]# ./goodbye
good-bye!
[root@logstash ~]# echo $?
66
[root@logstash ~]#
[root@logstash ~]# ./hello-goodby.sh
hello
[root@logstash ~]# echo $?
65
[root@logstash ~]#