loop structures
+2
akalya
jeeva
6 posters
loop structures
how to get a list of inputs from user n display them...using any loop
jeeva- Posts : 50
Points : 93
Join date : 2010-03-04
Re: loop structures
$cat list.sh
arr=$*
for a in $arr
do
echo $a
done
to execute:
$./list.sh 1 2 3 4 5
try this:)
arr=$*
for a in $arr
do
echo $a
done
to execute:
$./list.sh 1 2 3 4 5
try this:)
Last edited by akalya on Mon Mar 08, 2010 6:33 pm; edited 2 times in total
akalya- Posts : 70
Points : 86
Join date : 2010-03-04
Re: loop structures
for ((i = 0 ; i < 5 ; i++))
do
read var[i]
done
echo " ${var[*]} "
this ll work............give 5 inputs n try
do
read var[i]
done
echo " ${var[*]} "
this ll work............give 5 inputs n try
anand- Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36
Re: loop structures
akalya
i m gettin this
[335848@oracleclient ~]$ $./list 1 2 3 4
-bash: $./list: No such file or directory
aftr creatin list.sh also
i m gettin this
[335848@oracleclient ~]$ $./list 1 2 3 4
-bash: $./list: No such file or directory
aftr creatin list.sh also
lalitha- Posts : 14
Points : 16
Join date : 2010-03-08
Re: loop structures
@lalitha
first create a file named list.sh
then type the commands
save the file
then make it executable using chmod 755 list.sh
then execute the command ./list.sh
then only the program will execute!
first create a file named list.sh
then type the commands
save the file
then make it executable using chmod 755 list.sh
then execute the command ./list.sh
then only the program will execute!
Re: loop structures
You ve used $ twice.. That mite be the error
Saradha Kannan- Posts : 25
Points : 25
Join date : 2010-03-04
Permissions in this forum:
You cannot reply to topics in this forum
|
|