shell中,依次向同一脚本中传递不同的参数

来源:互联网 发布:泛型编程与stl pdf 编辑:程序博客网 时间:2024/05/04 19:26

=====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

 

 

哈哈 这个问题想了好久 .....郁闷死了

原创粉丝点击