shell脚本应用(5)--实用脚本片断
- if [ "$#" -ne 1 ]
- then
- echo "Incorrect number of arguments"
- echo "Usage: command arg1"
- exit 1
- fi
- prog1 &
- #获取prog1的pid
- pid1 = $1
- ...
- #等待后台prog1执行完继续脚本
- wait &pid
- #!/bin/bash
- read -p "please type the password:" PW
- echo $PW
- #!/bin/bash
- (echo "curpw"; sleep 1; echo "newpw"; sleep 1; echo "newpw") | passwd
- #!/bin/bash
- while true
- do
- #生成随机变量到input文件中,r能够是生成脚本
- ./r > input
- ./a < input > output.a
- ./b < input > output.b
- diff output.a output.b
- if [ $? -ne 0 ]
- then
- break
- fi
- done
欢迎关注本站公众号,获取更多信息