首页 > 代码库 > 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中需要注意的地方