shell中,依次向同一脚本中传递不同的参数
2012-09-18 00:25
393 查看
=====main.action======
#abc.sh
#!/bin/bash
echo -e "please in put the first number!"
read num1
if [ $num1 -eq 2 ];then
echo -e "please in put the second number!"
read num2
if [ $num2 == "abc" ];then
echo -e "the second number is : $num2"
else
echo -e "ERROR"
fi
else
echo -e "the first num is : $num1"
fi
=========================
=====a.txt========
2
abc
=================
运行方式:cat a.txt | sh abc.sh
哈哈 这个问题想了好久 .....郁闷死了
#abc.sh
#!/bin/bash
echo -e "please in put the first number!"
read num1
if [ $num1 -eq 2 ];then
echo -e "please in put the second number!"
read num2
if [ $num2 == "abc" ];then
echo -e "the second number is : $num2"
else
echo -e "ERROR"
fi
else
echo -e "the first num is : $num1"
fi
=========================
=====a.txt========
2
abc
=================
运行方式:cat a.txt | sh abc.sh
哈哈 这个问题想了好久 .....郁闷死了
相关文章推荐
- java调用shell脚本并传递参数
- shell调用php脚本,并传递参数
- Shell脚本传递带有空格的参数
- Shell之传递脚本参数与数组
- 将参数传递到awk内,用shell脚本提取符合条件的行
- 向shell脚本传递参数
- shell脚本程序函数参数传递
- shell脚本读取文本文件调用其他脚本传递获取参数
- shell脚本自动化部署-如何向expect脚本里面传递参数
- shell中脚本参数传递的两种方式
- shell 脚本中传递参数3种方法的比较
- shell脚本在执行时,向脚本传递参数
- Shell脚本传递带有空格的参数[摘录自网络]
- Shell脚本通过参数传递调用指定函数
- shell脚本参数传递和main函数参数传递方式类似
- shell 脚本之获取命令输出字符串以及函数参数传递
- shell 脚本中传递参数3种方法的比较
- 解决shell脚本参数传递含有空格的问题
- Shell脚本中参数传递方法常用有8种
- ant给shell脚本传递参数