How to pass values on commandline in shell script :
==============
#!/bin/bash
for i in $@
do
echo $i
s=$i
if [ "$s" -lt "3" ]
then
echo "$s"
fi
done
==============
Output : # sh t2.sh 4 5 6
4
5
6
Output : # sh t2.sh 1 2 3 4
1
1 is less than 3
2
2 is less than 3
3
4
==============
#!/bin/bash
for i in $@
do
echo $i
s=$i
if [ "$s" -lt "3" ]
then
echo "$s"
fi
done
==============
Output : # sh t2.sh 4 5 6
4
5
6
Output : # sh t2.sh 1 2 3 4
1
1 is less than 3
2
2 is less than 3
3
4
Comments
Post a Comment