开始学习Shell脚本。
#!/bin/bash if [ $UID -ne 0 ]; then echo "you are not root" else echo "you are root" fi var="hello world" echo $var echo ${var} echo "var is $var" echo 'var is $var' echo "length of var is ${#var}"
注意点:
1. var="hello world",等号两边不要有空格。
2. 变量替换在单引号中无效。
参考资料:
《Linux Shell 脚本攻略》