- 校验参数
- 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
- ACM用测试数据检验程序正确与否
- #!/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