
Bash Array Quiz

Quiz
•
Computers
•
University
•
Hard
Amal Redge
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you declare an array in Bash?
array_name = (value1 value2 value3)
array_name = [value1 value2 value3]
array_name = {value1 value2 value3}
array_name =
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to access the third element of an array named my_array?
${my_array[2]}
${my_array[3]}
${my_array[1]}
${my_array[0]}
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which command is used to get the length of an array in Bash?
${#array_name}
${array_name[@]}
${#array_name[@]}
${array_name[*]}
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you append a value to an existing array in Bash?
array_name += value
array_name[] = value
array_name += (value)
array_name+=(value)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? array=(1 2 3 4 5) echo ${array[@]:1:3}
1 2 3
2 3 4
3 4 5
2 3 4 5
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you iterate over all elements of an array named my_array?
for i in ${my_array[*]}; do echo $i; done
for i in ${my_array[@]}; do echo $i; done
for i in ${my_array}; do echo $i; done
for i in ${my_array[0]}; do echo $i; done
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is the correct way to declare an associative array in Bash?
declare -A array_name
declare -a array_name
declare -A array_name[]
declare -a array_name[]
Create a free account and access millions of resources
Similar Resources on Wayground
12 questions
JavaScript Quiz

Quiz
•
University
10 questions
LINUX MODULE 03 QUIZ

Quiz
•
University
15 questions
Arrays and Pointers in C

Quiz
•
University
12 questions
Fundamentos de Shell Script

Quiz
•
11th Grade - University
15 questions
[Python For All] Quiz 5 - Numpy

Quiz
•
University
15 questions
module3

Quiz
•
University
10 questions
Linux Fail Show: Comando ou Consequência

Quiz
•
University
10 questions
DIS08_1_Shell

Quiz
•
University
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
10 questions
"LAST STOP ON MARKET STREET" Vocabulary Quiz

Quiz
•
3rd Grade
19 questions
Fractions to Decimals and Decimals to Fractions

Quiz
•
6th Grade
16 questions
Logic and Venn Diagrams

Quiz
•
12th Grade
15 questions
Compare and Order Decimals

Quiz
•
4th - 5th Grade
20 questions
Simplifying Fractions

Quiz
•
6th Grade
20 questions
Multiplication facts 1-12

Quiz
•
2nd - 3rd Grade