Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

loop structures

+2
akalya
jeeva
6 posters

Go down

loop structures Empty loop structures

Post by jeeva 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

Back to top Go down

loop structures Empty Re: loop structures

Post by akalya 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

Back to top Go down

loop structures Empty Re: loop structures

Post by anand 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
anand
anand

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

Back to top Go down

loop structures Empty Re: loop structures

Post by lalitha 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

Back to top Go down

loop structures Empty Re: loop structures

Post by mightyganesh 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
mightyganesh
mightyganesh

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

http://ganeshguna.blogspot.com

Back to top Go down

loop structures Empty Re: loop structures

Post by Saradha Kannan 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

Back to top Go down

loop structures Empty 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