首页 > 代码库 > shell中需要注意的地方
shell中需要注意的地方
[root@VM_48_191_centos 456]# vim 2.sh
#!/bin/bash #加入这行,表示解释器是bash,不加也可以,我是centos的,默认是bash
echo $0
echo $1
[root@VM_48_191_centos 456]# ./2.sh 1
./2.sh
1
[root@VM_48_191_centos 456]# ./2.sh 2
./2.sh
2
[root@VM_48_191_centos 456]# sh 2.sh 2
2.sh
2
./执行脚本的时候,$0就是./执行脚本
而使用sh 执行的时候,$0就是脚本名字
本文出自 “飞奔的小GUI” 博客,请务必保留此出处http://9237101.blog.51cto.com/9227101/1929676
shell中需要注意的地方
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。