./script.sh和bash script.sh有什么区别 [英] what's the difference between ./script.sh and bash script.sh

查看:89
本文介绍了./script.sh和bash script.sh有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在linux系统上,在这两种不同的方式下script.sh的踢动有什么区别吗?

On linux system, is there any difference to kick of script.sh in these two different ways?

它们是完全一样的东西吗?

Are they exactly the same thing?

谢谢

推荐答案

./script.sh期望该文件位于当前目录中,并已设置了执行位,并且文件的第一行是解释器开始的路径与(蛇帮线)

./script.sh expects that this file is in the current directory, has execute bit set and the first line of the file is path to the interpreter to start with ( Shebang line )

bash script.sh意味着您调用bash并将要执行(解释)的文件内容作为bash命令传递.这样,您的文件就无需可执行,并且具有一个shebang行.

bash script.sh means that you invoke bash and pass the contents of the file to be executed(interpreted) as bash commands. This way your file doesn't need to be executable and has a shebang line.

如果满足./script.sh的条件,则两次调用将导致相同的结果.

If the conditions for ./script.sh are met then both invocations lead to the same result.

这篇关于./script.sh和bash script.sh有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆