实现同一个文档,不同的帮助文档!

实验目的:源文件,与他的软连接文件,实现其获取到的帮助不一样!

为了让大家更直观的了解该知识点,我在这里先给大家举一个简单的例子!

一、编写一个简单的脚本吧。

[root@localhost app]# vim test.sh 
[root@localhost app]# cat test.sh 
#!/bin/bash
if [ $0 == './test.sh' ];then
	echo hello
else
	echo haha
fi

简单的解释一下:如果我执行test.sh脚本的话,弹出hello,否则弹出haha。

二、给test.sh脚本加上执行权限,并创建一个软连接。

[root@localhost app]# chmod +x test.sh
[root@localhost app]# ln -s test.sh test2.sh
[root@localhost app]# ll
total 4
lrwxrwxrwx. 1 root root  7 Oct 12 08:40 test2.sh -> test.sh
-rwxr-xr-x. 1 root root 80 Oct 12 08:39 test.sh

三、测试

[root@localhost app]# ./test.sh 
hello
[root@localhost app]# ./test2.sh 
haha

看到了吧!test.sh和test2.sh是一个文件,我们执行同样的脚本,出来的结果居然不一样!

你看懂了吗?

 

----------------------当你的能力不能够满足你的野心,那就静下心来学习吧!----------------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值