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
歡迎關注本站公眾號,獲取更多信息