loop structures

Go down

loop structures

Post by jeeva on Mon Mar 08, 2010 4:14 pm

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

View user profile

Back to top Go down

Re: loop structures

Post by akalya on Mon Mar 08, 2010 4:28 pm

$cat list.sh

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

View user profile

Back to top Go down

Re: loop structures

Post by anand on Mon Mar 08, 2010 4:43 pm

for ((i = 0 ; i < 5 ; i++))
do
read var[i]
done

echo " ${var[*]} "

this ll work............give 5 inputs n try
avatar
anand

Posts : 55
Points : 70
Join date : 2010-02-26
Age : 30

View user profile

Back to top Go down

Re: loop structures

Post by lalitha on Mon Mar 08, 2010 6:17 pm

akalya
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

View user profile

Back to top Go down

Re: loop structures

Post by mightyganesh on Mon Mar 08, 2010 6:23 pm

@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! Idea
avatar
mightyganesh

Posts : 53
Points : 92
Join date : 2010-02-26
Age : 30

View user profile http://ganeshguna.blogspot.com

Back to top Go down

Re: loop structures

Post by Saradha Kannan on Mon Mar 08, 2010 6:24 pm

You ve used $ twice.. That mite be the error

Saradha Kannan

Posts : 25
Points : 25
Join date : 2010-03-04

View user profile

Back to top Go down

Re: loop structures

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum