Deck 10: Shell Scripting

ملء الشاشة (f)
exit full mode
سؤال
A user needs the following permissions to be able to use a script as a command

A) Read and write
B) Write
C) Read
D) Execute
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The pipe operator, which directs the output from one command to another, is

A) /
B) #
C) |
D) >
سؤال
Consider the following script. The output will be newlines replaced by spaces for brevity): #! /bin/bash
for number in {51}\{ 5 \ldots 1 \}
do
echo snumber
done

A) 5 .. 1
B) 5 4 3 2 1
C) 1 2 3 4 5
D) 5 3 1
سؤال
The command to view the contents of a variable at the shell prompt is

A) variablename
B) echo variablename
C) echo $variablename
D) $variablename
سؤال
Consider the following script. The output will be newlines replaced by spaces):#! /bin/bash
for number in {713}\{ 7 \ldots 1 \ldots 3 \}
do
echo snumber
done

A) 1 3 5 7
B) 1 4
C) 1 4 7
D) 7 4 1
سؤال
The cat command in Linux is used to

A) Edit a shell script
B) Execute a shell script
C) Display the contents of a file
D) Find files
سؤال
Consider the following script. The output will be:
#! /bin/bash
guess = 2
start = 3
check = $     $start ÷2)+1)\div 2 ) + 1 ) )
if [ $guess -eq $check]
then
echo "Correct Guess: The number is $start"
else
echo "Sorry, wrong guess"

A) Correct Guess: The number is 3
B) Correct Guess: The number is 2
C) Sorry, wrong guess
D) Indeterminate
سؤال
File users.csv contains lines as: Christine:Riggs:christine.riggs@sunshine.edu. The command to extract emails from the file is

A) cut -d: -f3 users.csv
B) cut -d, -f3 users.csv
C) cut -d: -f1,2,3 users.csv
D) cut -d, -f1,2,3 users.csv
سؤال
Consider the following script. The output will be newlines replaced by spaces): #! / bin/bash
for number in {173}\{ 1 \ldots 7 \ldots 3 \}
do
echo $number
done

A) 1 3 5 7
B) 1 4
C) 1 4 7
D) 7 4 1
سؤال
In programming languages, loops are used to

A) Loop through the execution logic and understand the program
B) Collect all comments
C) Mark the beginning and end of the program
D) Repeat a set of commands
سؤال
Comment lines in script begin with the character

A) /
B) #
C) |
D) >
سؤال
Shell scripts are

A) A list of shell commands in a text file
B) Scripts used as a shell, with no content until used
C) A type of compiled programs
D) Lists of drugs prescribed by a physician
سؤال
The redirect operator used to send the output of a command to a file is written as

A) /
B) #
C) |
D) >
سؤال
Consider the following script. The output will be: #! /bin/bash
guess=2
check=$ $RANDOM ÷2)+1)\left. \left. \div 2 \right) + 1 \right) )
if [ $guess -eq $check]
then
echo "Correct Guess: The number is $check"
else echo "Sorry, wrong guess"

A) Correct Guess: The number is 3
B) Indeterminate
C) Correct Guess: The number is 2
D) Sorry, wrong guess
سؤال
A specific set of commands is to be executed 10 times. The most appropriate loop construct to accomplish this is

A) for
B) while
C) do
D) if
سؤال
Shell scripts can obtain user input using the command

A) input
B) var
C) read
D) cat
سؤال
The command that will create a new variable in a bash script is

A) let firstname = "John"
B) firstname="John"
C) string firstname = "John"
D) str firstname = "John"
سؤال
The first line of an executable script needs to be #!/bin/bash, in order to

A) Inform the shell which shell interpreter to use to execute the script
B) Remind the user of the shell interpreter to use when executing the script
C) Remind the user of the shell interpreter used to create the script
D) Serve as a comment for the shell interpreter when executing the script
سؤال
Shell scripts are used for

A) Serving as firewalls
B) Automating processes in operating systems
C) End-point protection
D) Detecting intrusions
سؤال
Environment variables are

A) Variables describing the user's access to the computer environment
B) Variables describing the local climate
C) Variables describing the state of the host system
D) Variables created automatically when a user starts a new terminal window
سؤال
Consider the following script. The output will be newlines replaced by spaces for brevity): #! /bin/bash
counter=1
while [ \$counter -le 5]
do
\quad echo $counter
\quad counter=$counter +1)+ 1 ) )
done

A) 5 .. 1
B) 5 4 3 2 1
C) 1 2 3 4 5
D) 5 3 1
سؤال
The difference between break and continue while processing loop input is that

A) break exits the loop, but continue only exits the current iteration of the loop
B) break only exits the current iteration of the loop, but continue exits the loop
C) break and continue exit the loop
D) break and continue both exit only the current iteration of the loop
سؤال
A specific set of commands is to be executed until a pre-specified condition is reached. The most appropriate loop construct to accomplish this is

A) for
B) while
C) do
D) if
سؤال
An infinite loop a loop that runs forever can sometimes be useful
سؤال
Consider the following script. The output will be newlines replaced by spaces for brevity): #! /bin/bash
counter=1
while [ $counter -le 2]
do
echo $counter
done

A) 5 .. 1
B) 5 4 3 2 1
C) 1 2 3 4 5
D) 1 1 1 1 1 1 ……. indefinitely)
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 10: Shell Scripting
1
A user needs the following permissions to be able to use a script as a command

A) Read and write
B) Write
C) Read
D) Execute
Execute
2
The pipe operator, which directs the output from one command to another, is

A) /
B) #
C) |
D) >
C
3
Consider the following script. The output will be newlines replaced by spaces for brevity): #! /bin/bash
for number in {51}\{ 5 \ldots 1 \}
do
echo snumber
done

A) 5 .. 1
B) 5 4 3 2 1
C) 1 2 3 4 5
D) 5 3 1
5 4 3 2 1
4
The command to view the contents of a variable at the shell prompt is

A) variablename
B) echo variablename
C) echo $variablename
D) $variablename
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
5
Consider the following script. The output will be newlines replaced by spaces):#! /bin/bash
for number in {713}\{ 7 \ldots 1 \ldots 3 \}
do
echo snumber
done

A) 1 3 5 7
B) 1 4
C) 1 4 7
D) 7 4 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
6
The cat command in Linux is used to

A) Edit a shell script
B) Execute a shell script
C) Display the contents of a file
D) Find files
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
7
Consider the following script. The output will be:
#! /bin/bash
guess = 2
start = 3
check = $     $start ÷2)+1)\div 2 ) + 1 ) )
if [ $guess -eq $check]
then
echo "Correct Guess: The number is $start"
else
echo "Sorry, wrong guess"

A) Correct Guess: The number is 3
B) Correct Guess: The number is 2
C) Sorry, wrong guess
D) Indeterminate
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
8
File users.csv contains lines as: Christine:Riggs:christine.riggs@sunshine.edu. The command to extract emails from the file is

A) cut -d: -f3 users.csv
B) cut -d, -f3 users.csv
C) cut -d: -f1,2,3 users.csv
D) cut -d, -f1,2,3 users.csv
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
9
Consider the following script. The output will be newlines replaced by spaces): #! / bin/bash
for number in {173}\{ 1 \ldots 7 \ldots 3 \}
do
echo $number
done

A) 1 3 5 7
B) 1 4
C) 1 4 7
D) 7 4 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
10
In programming languages, loops are used to

A) Loop through the execution logic and understand the program
B) Collect all comments
C) Mark the beginning and end of the program
D) Repeat a set of commands
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
11
Comment lines in script begin with the character

A) /
B) #
C) |
D) >
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
12
Shell scripts are

A) A list of shell commands in a text file
B) Scripts used as a shell, with no content until used
C) A type of compiled programs
D) Lists of drugs prescribed by a physician
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
13
The redirect operator used to send the output of a command to a file is written as

A) /
B) #
C) |
D) >
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
14
Consider the following script. The output will be: #! /bin/bash
guess=2
check=$ $RANDOM ÷2)+1)\left. \left. \div 2 \right) + 1 \right) )
if [ $guess -eq $check]
then
echo "Correct Guess: The number is $check"
else echo "Sorry, wrong guess"

A) Correct Guess: The number is 3
B) Indeterminate
C) Correct Guess: The number is 2
D) Sorry, wrong guess
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
15
A specific set of commands is to be executed 10 times. The most appropriate loop construct to accomplish this is

A) for
B) while
C) do
D) if
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
16
Shell scripts can obtain user input using the command

A) input
B) var
C) read
D) cat
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
17
The command that will create a new variable in a bash script is

A) let firstname = "John"
B) firstname="John"
C) string firstname = "John"
D) str firstname = "John"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
18
The first line of an executable script needs to be #!/bin/bash, in order to

A) Inform the shell which shell interpreter to use to execute the script
B) Remind the user of the shell interpreter to use when executing the script
C) Remind the user of the shell interpreter used to create the script
D) Serve as a comment for the shell interpreter when executing the script
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
19
Shell scripts are used for

A) Serving as firewalls
B) Automating processes in operating systems
C) End-point protection
D) Detecting intrusions
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
20
Environment variables are

A) Variables describing the user's access to the computer environment
B) Variables describing the local climate
C) Variables describing the state of the host system
D) Variables created automatically when a user starts a new terminal window
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
21
Consider the following script. The output will be newlines replaced by spaces for brevity): #! /bin/bash
counter=1
while [ \$counter -le 5]
do
\quad echo $counter
\quad counter=$counter +1)+ 1 ) )
done

A) 5 .. 1
B) 5 4 3 2 1
C) 1 2 3 4 5
D) 5 3 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
22
The difference between break and continue while processing loop input is that

A) break exits the loop, but continue only exits the current iteration of the loop
B) break only exits the current iteration of the loop, but continue exits the loop
C) break and continue exit the loop
D) break and continue both exit only the current iteration of the loop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
23
A specific set of commands is to be executed until a pre-specified condition is reached. The most appropriate loop construct to accomplish this is

A) for
B) while
C) do
D) if
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
24
An infinite loop a loop that runs forever can sometimes be useful
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
25
Consider the following script. The output will be newlines replaced by spaces for brevity): #! /bin/bash
counter=1
while [ $counter -le 2]
do
echo $counter
done

A) 5 .. 1
B) 5 4 3 2 1
C) 1 2 3 4 5
D) 1 1 1 1 1 1 ……. indefinitely)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.