Shell脚本执行的四种方法
发布时间:2020-12-15 22:09:03 所属栏目:安全 来源:网络整理
导读:(1).bash [脚本名称] [[email?protected] ~]$ cat a.sh#!/bin/bashecho "hello world!"[[email?protected] ~]$ bash a.shhello world![[email?protected] ~]$ which bash/usr/bin/bash (2).sh [脚本名称] 实际上sh指向的也是bash [[email?protected] ~]$ sh
(1).bash [脚本名称] [[email?protected] ~]$ cat a.sh #!/bin/bash echo "hello world!" [[email?protected] ~]$ bash a.sh hello world! [[email?protected] ~]$ which bash /usr/bin/bash (2).sh [脚本名称] 实际上sh指向的也是bash [[email?protected] ~]$ sh a.sh hello world! [[email?protected] ~]$ which sh /usr/bin/sh [[email?protected] ~]$ ll /usr/bin/sh lrwxrwxrwx. 1 root root 4 4月 5 22:07 /usr/bin/sh -> bash (3).使用./[脚本名称],但脚本文件必须有执行权限 [[email?protected] ~]$ chmod +x a.sh [[email?protected] ~]$ ./a.sh hello world! (4).使用绝对路径,脚本文件一样需要执行权限 [[email?protected] ~]$ /home/xf/a.sh hello world! [[email?protected] ~]$ ll a.sh -rwxrwxr-x. 1 xf xf 32 5月 3 16:01 a.sh (5).sh < [脚本名称]或者cat [脚本名称] | sh(bash) [[email?protected] ~]$ sh<a.sh hello world! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容