bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Selecting out of an array


From: Jon_R
Subject: Selecting out of an array
Date: Mon, 25 Jan 2010 17:28:05 -0800 (PST)

Hello List,

I am new to shell scripting and programming in general, so please excuse my
ignorance. :)

I am trying to setup a menu for some videos that I have so that you can
select one and it will play it using xine or mplayer. My first attempt was
to assign each video a variable name and then I could select which video and
then play it. This is not very efficient because I always have to assign a
new variable to a new video.

I am now trying to populate an array using the 'ls' command. I have attached
the script below.

This gives me this as output to the screen:
   0: video1
   1: video10
   2: video11
   3: video2
   4: video3
   5: video4
   6: video5
   7: video6
   8: video7
   9: video8
  10: video9
1) video9
#?

I get the prompt waiting for me to make a selection "#?". I then have a
'printf' statement that should print out my selection using the index number
but it is not working. When I choose '1' I get video9 even though it is
index number 10. 

Why does it even print "1) video9" when it should be waiting for input from
the user?

http://old.nabble.com/file/p27316649/newsh2.sh newsh2.sh 

Thanks for any help,

Jon
-- 
View this message in context: 
http://old.nabble.com/Selecting-out-of-an-array-tp27316649p27316649.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]