0

I have an array myvideos which contained few elements, say, "Intel","NVIDIA",and "RANDON", how to use myvideos as selector elements? As shown below, I'm able to get one element of myvideos. Any ideas? Thank you!

oVideos=$Videos
Videos="Please select a video card: "
select myvideo in "$myvideos"
do
    ...
done
6
  • Have you tried putting the title of your question into Google? Please add what code you've tried so far. Commented Nov 6, 2015 at 23:57
  • 1
    please edit your code to include a definition for $myvideos. Good luck. Commented Nov 6, 2015 at 23:58
  • 2
    Change "RANDON" to "RADEON", that should fix it. Commented Nov 6, 2015 at 23:59
  • 1
    Your question is incomplete, but I think you are looking for select myvideo in ${myvideos[@]} Commented Nov 6, 2015 at 23:59
  • 1
    How are you setting myvideos? My guess is you don't actually have an array. Commented Nov 7, 2015 at 1:59

2 Answers 2

3

Using select:

#! /bin/bash

MyVideos=("INTEL" "NVIDIA" "RANDONONNJSDHF")
PS3="Please select a video card: "
select myvideo in ${MyVideos[@]}
do
    echo "$myvideo selected"
done
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much dtmilano. Thank you everybody! Appreciate your time.
0

Maybe this example can help you shed some light:

[aesteban@localhost ~]$ MyVideos=("INTEL" "NVIDIA" "RANDONONNJSDHF")
[aesteban@localhost ~]$ 
[aesteban@localhost ~]$ for entry in "${MyVideos[@]}"; do echo $entry; done;
INTEL
NVIDIA
RANDONONNJSDHF
[aesteban@localhost ~]$ 

Good luck!!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.