1. shell脚本for循环读取数据 。例如:读取上一级目录,循环打印出来。
for file in `ls ../`;do
echo ${file}
done
2. 获取字符串长度(使用${#} 获取字符创长度)
var="0123456789abcdef"
length=${#var}
3. 截取字符串(从第2个字符开始,截取5个字符出来)
string="reboot is start"
echo ${string:1:5} 输出eboot
4. $0, $1, $2, $3 意思 ./shell.sh 12 ab
echo "shell 执行文件名:$0" ; //$0 shell文件名
echo "第一个参数:$1";// $1第一个参数 12
echo "第二个参数:$2";//$2第二个参数 ab
5. ./shell & '&' 表示进程是后台运行。
6. 文件符号