shell脚本应用(5)--实用脚本片段
2014-02-26 21:29
429 查看
校验参数
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
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
相关文章推荐
- Shell脚本典型应用
- Shell 脚本分割变量分别赋值与sed 应用打印特殊行
- 5个实用的shell脚本面试题和答案
- 老男孩教育每日一题:2017年3月9日-请解释下面Shell脚本中if开头的整行代码的意思及应用场景吗?
- awk和sed 应用shell脚本变量
- 【Shell】【学习笔记】Linux Shell脚本应用(五)
- 应用python编写shell脚本
- shell脚本应用(一)
- Shell脚本应用之服务启动脚本
- Android开发中高效实用的shell命令脚本
- Shell 脚本介绍之date 应用
- 运维工程师工作中实用shell脚本与语句
- 9.4 shell脚本应用2
- 9.6 shell脚本应用3
- 实用脚本----Linux下Jdk和Tomcat自动安装shell脚本总结
- 实用shell脚本 安装集群使用
- 使用shell脚本实现客户端应用自动化打包——mac
- shell企业级实用基础脚本(汇总1/2)
- 【Shell】【学习笔记】Linux Shell脚本应用(六)
- shell脚本应用(一)